Display for the slider value


I am looking to use a slider for an app to provide lower and upper ranges on a parameter.
From the documentation i can see that the ‘format’ attribute is to be used to control the display.

Have map/dict which relates to an integer to a grade (chars, e.g. A+).

grade_map = {
1: A+,
2: A,

grade = st.slider(‘select grade filter?’, 1, 10, 1)

want the slider to display the start/end range/selected value as str instead of number.

Can you please let me know if it is possible and how to make it work?


Hey @sahilk2418 , Welcome to the forums! :tada:

The slider component is meant to be used with numbers and the format parameter it’s only used for how the numbers should be shown using a printf style , so there’s no way to do that with just that element but you could do something like this:

grade_map = {
    1: 'A +',
    2: 'A',
    3: 'A -',

grade = st.slider('Select grade filter?', 1, 3, 1)
st.write('Selected grade:' + grade_map[grade])

From my point of view you could use st.selectbox() that I think is more appropriate for this case:

st.selectbox('Select grade filter?', list(grade_map.values()))

Hello @arraydude, thanks for checking this.

I was also thinking of using the select box, but wanted to know if there is any plan in future to support alpha/numeric sliders.


@sahilk2418 I’ve created a feature request here for you