Styling st.slider label

Hi I have read the docs and it mentions that st.slider ā€˜labelā€™ can include ā€˜inline codeā€™.
I have tried this:

st.slider(f'''<p class="res">{col}</p>''', min_value = float(min_val), max_value = float(max_val), value = float(val))

This adds the label to a stMarkdownContainer div, however it copies the inline code instead of passing it.

image

The labels accept a subset of Markdown, which doesnā€™t include raw HTML unfortunately. So if you want to make the label bold, you could have

st.slider(f'**{col}**', min_value = float(min_val), max_value = float(max_val), value = float(val))

If you are looking for something more elaborate, you would have to inject some CSS to grab the element by other means.

2 Likes

Just to clarify: by ā€˜inline codeā€™ we mean the <code> HTML element:

Thank you so much for your answer, it would be nice to be able to add a CSS class to any element.
For now I will stick with bold :slight_smile:

Thank you, although I cant think of may reasons you would want to dispay a code snippet as a slider label :slight_smile:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.