[go: up one dir, main page]

Input widgets

With widgets, Streamlit allows you to bake interactivity directly into your apps with buttons, sliders, text inputs, and more.

screenshot

Button

Display a button widget.

Python
clicked = st.button("Click me")
screenshot

Download button

Display a download button widget.

Python
st.download_button("Download file", file)
screenshot

Form button

Display a form submit button. For use with st.form.

Python
st.form_submit_button("Sign up")
screenshot

Link button

Display a link button.

Python
st.link_button("Go to gallery", url)
screenshot

Page link

Display a link to another page in a multipage app.

Python
st.page_link("app.py", label="Home", icon="🏠")
st.page_link("pages/profile.py", label="My profile")
screenshot

Checkbox

Display a checkbox widget.

Python
selected = st.checkbox("I agree")
screenshot

Color picker

Display a color picker widget.

Python
color = st.color_picker("Pick a color")
screenshot

Feedback

Display a rating or sentiment button group.

Python
st.feedback("stars")
screenshot

Multiselect

Display a multiselect widget. The multiselect widget starts as empty.

Python
choices = st.multiselect("Buy", ["milk", "apples", "potatoes"])
screenshot

Pills

Display a pill-button selection widget.

Python
st.pills("Tags", ["Sports", "AI", "Politics"])
screenshot

Radio

Display a radio button widget.

Python
choice = st.radio("Pick one", ["cats", "dogs"])
screenshot

Segmented control

Display a segmented-button selection widget.

Python
st.segmented_control("Filter", ["Open", "Closed", "All"])
screenshot

Select slider

Display a slider widget to select items from a list.

Python
size = st.select_slider("Pick a size", ["S", "M", "L"])
screenshot

Selectbox

Display a select widget.

Python
choice = st.selectbox("Pick one", ["cats", "dogs"])
screenshot

Toggle

Display a toggle widget.

Python
activated = st.toggle("Activate")
screenshot

Number input

Display a numeric input widget.

Python
choice = st.number_input("Pick a number", 0, 10)
screenshot

Slider

Display a slider widget.

Python
number = st.slider("Pick a number", 0, 100)
screenshot

Date input

Display a date input widget.

Python
date = st.date_input("Your birthday")
screenshot

Datetime input

Display a datetime input widget.

Python
datetime = st.datetime_input("Schedule your event")
screenshot

Time input

Display a time input widget.

Python
time = st.time_input("Meeting time")
screenshot

Text input

Display a single-line text input widget.

Python
name = st.text_input("First name")
screenshot

Text area

Display a multi-line text input widget.

Python
text = st.text_area("Text to translate")
screenshot

Chat input

Display a chat input widget.

Python
prompt = st.chat_input("Say something")
if prompt:
    st.write(f"The user has sent: {prompt}")
screenshot

Audio input

Display a widget that allows users to record with their microphone.

Python
speech = st.audio_input("Record a voice message")
screenshot

Data editor

Display a data editor widget.

Python
edited = st.data_editor(df, num_rows="dynamic")
screenshot

File uploader

Display a file uploader widget.

Python
data = st.file_uploader("Upload a CSV")
screenshot

Camera input

Display a widget that allows users to upload images directly from a camera.

Python
image = st.camera_input("Take a picture")

Third-party components

These are featured components created by our lovely community. For more examples and inspiration, check out our Components Gallery and Streamlit Extras!

screenshot

Stqdm

The simplest way to handle a progress bar in streamlit app. Created by @Wirg.

Python
from stqdm import stqdm

for _ in stqdm(range(50)):
    sleep(0.5)
screenshot

Timeline

Display a Timeline in Streamlit apps using TimelineJS. Created by @innerdoc.

Python
from streamlit_timeline import timeline

with open('example.json', "r") as f:
  timeline(f.read(), height=800)
screenshot

Camera input live

Alternative for st.camera_input which returns the webcam images live. Created by @blackary.

Python
from camera_input_live import camera_input_live

image = camera_input_live()
st.image(value)
forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.