import streamlit as st # Function to create a slider with an edit bar. The name of the slider must be unique on the page. def createSliderWithEdit(container, initialValue, sliderName): val = initialValue # session_state is a global object, associated with streamlit, not with the container if sliderName in st.session_state: val = st.session_state[sliderName] nb = container.number_input(label=sliderName, value=val) # When you add a Key to the slider it will automatically create a session state associated with it. v = container.number_input(label='', value=nb, key=sliderName) # v = container.slider(label='', value=nb, key=sliderName) createSliderWithEdit(st, 0, 'MyFavoriteInput') createSliderWithEdit(st, 0, 'MySecondFavoriteInput') col1, col2 = st.columns(2) createSliderWithEdit(col1, 0, 'FirstInputInAColumn') createSliderWithEdit(col2, 0, 'SecondInputInAColumn')
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter