Say, is it possible to have the number_input widget NOT show the -/+ stepper ?
I have an app with tens of numeric inputs that are miscellaneous physical quantities…a stepper does not make sense and it is getting in the way of a smooth user experience.
The way that it bother the user experience is when tabbing from one input to the next, without the stepper, a single tab would take me to the next input; with the stepper, I need to tab 3 times !!
I need two widgets, one for the label and one for the number
It will be my responsibility to validate and make sure the entry can be converted to a number and/or not allowed the typing of non-numeric characters (when is the callback called? after typing every character or until pressing enter or tab?)
You just need 1 widget - the label is part of the widget
Yes, you will have to validate the user entry. For invalid inputs, you can blank the entry via the session state[key of your widget] = ‘’. You could also add a conditional st.error within the callback
Optional stepper would be really nice to have, so that the other functionality of number_input() can be reused when the stepper hurts the UX. I suggest you file a feature request.
That’s true, @Goyo. For that reason, I just used st.text_input in my scenario, as the field can have an empty string.
number = st.text_input('Enter your number', placeholder='000')
if number != '':
try:
number = int(number) # try to convert the variable to an integer
except ValueError: # if it's not convertible, catch the ValueError exception
st.markdown(f"Oh no 😱 **:red[{number}]** is NOT a number")
And yes, having the option to display or not display the stepper buttons would be great. This feature has already been suggested here on Dec 24, 2019
2021-Feb, CFrez created pull-request #2791 and proposed an implementation of the freature
2021-Mar, somebody from the product team denied the request and closed it
2021-Sep, ks00x opened issue #3630; it was marked as duplicate of #894 and closed
2022- , user continue to show interest on this feature request
2023-Feb, latest post to issue #894 by walsha2 with proposed remedy; thought, I presonally don’t know what to do with it, where to place it, how to use it.
So, yes, this feature request has been kicked around for 3 years…but no cigar.
Hey, @gsal , I don’t know if you saw the latest releases, but now, a single tab can bring you to the next input, not three anymore. Basically, the steps are ignored when using tab.