One option, though it’s not a general-purpose solution to formatting:
def formatter (x):
try:
return str(x).replace(' ','⬛')
except:
return x
with st.form('my_form'):
st.selectbox('Choose',[' This is an option','This is an option','This is an option ', 'This is an option '], index=0, format_func=formatter)
st.form_submit_button('submit')
Logic could be changed if you only want to highlight leading, trailing and double spaces.
