eagle0504's picture
app updated
746d2f1
---
title: Input widgets
slug: /develop/api-reference/widgets
---
# Input widgets
With widgets, Streamlit allows you to bake interactivity directly into your apps with buttons, sliders, text inputs, and more.
## Button elements
<TileContainer>
<RefCard href="/develop/api-reference/widgets/st.button">
<Image pure alt="screenshot" src="/images/api/button.svg" />
<h4>Button</h4>
Display a button widget.
```python
clicked = st.button("Click me")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.download_button">
<Image pure alt="screenshot" src="/images/api/download_button.svg" />
<h4>Download button</h4>
Display a download button widget.
```python
st.download_button("Download file", file)
```
</RefCard>
<RefCard href="/develop/api-reference/execution-flow/st.form_submit_button">
<Image pure alt="screenshot" src="/images/api/form_submit_button.svg" />
<h4>Form button</h4>
Display a form submit button. For use with `st.form`.
```python
st.form_submit_button("Sign up")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.link_button">
<Image pure alt="screenshot" src="/images/api/link_button.svg" />
<h4>Link button</h4>
Display a link button.
```python
st.link_button("Go to gallery", url)
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.page_link">
<Image pure alt="screenshot" src="/images/api/page_link.jpg" />
<h4>Page link</h4>
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")
```
</RefCard>
</TileContainer>
## Selection elements
<TileContainer>
<RefCard href="/develop/api-reference/widgets/st.checkbox">
<Image pure alt="screenshot" src="/images/api/checkbox.jpg" />
<h4>Checkbox</h4>
Display a checkbox widget.
```python
selected = st.checkbox("I agree")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.toggle">
<Image pure alt="screenshot" src="/images/api/toggle.jpg" />
<h4>Toggle</h4>
Display a toggle widget.
```python
activated = st.toggle("Activate")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.radio">
<Image pure alt="screenshot" src="/images/api/radio.jpg" />
<h4>Radio</h4>
Display a radio button widget.
```python
choice = st.radio("Pick one", ["cats", "dogs"])
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.selectbox">
<Image pure alt="screenshot" src="/images/api/selectbox.jpg" />
<h4>Selectbox</h4>
Display a select widget.
```python
choice = st.selectbox("Pick one", ["cats", "dogs"])
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.multiselect">
<Image pure alt="screenshot" src="/images/api/multiselect.jpg" />
<h4>Multiselect</h4>
Display a multiselect widget. The multiselect widget starts as empty.
```python
choices = st.multiselect("Buy", ["milk", "apples", "potatoes"])
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.select_slider">
<Image pure alt="screenshot" src="/images/api/select_slider.jpg" />
<h4>Select slider</h4>
Display a slider widget to select items from a list.
```python
size = st.select_slider("Pick a size", ["S", "M", "L"])
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.color_picker">
<Image pure alt="screenshot" src="/images/api/color_picker.jpg" />
<h4>Color picker</h4>
Display a color picker widget.
```python
color = st.color_picker("Pick a color")
```
</RefCard>
</TileContainer>
## Numeric input elements
<TileContainer>
<RefCard href="/develop/api-reference/widgets/st.number_input">
<Image pure alt="screenshot" src="/images/api/number_input.jpg" />
<h4>Number input</h4>
Display a numeric input widget.
```python
choice = st.number_input("Pick a number", 0, 10)
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.slider">
<Image pure alt="screenshot" src="/images/api/slider.jpg" />
<h4>Slider</h4>
Display a slider widget.
```python
number = st.slider("Pick a number", 0, 100)
```
</RefCard>
</TileContainer>
## Date and time input elements
<TileContainer>
<RefCard href="/develop/api-reference/widgets/st.date_input">
<Image pure alt="screenshot" src="/images/api/date_input.jpg" />
<h4>Date input</h4>
Display a date input widget.
```python
date = st.date_input("Your birthday")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.time_input">
<Image pure alt="screenshot" src="/images/api/time_input.jpg" />
<h4>Time input</h4>
Display a time input widget.
```python
time = st.time_input("Meeting time")
```
</RefCard>
</TileContainer>
## Text input elements
<TileContainer>
<RefCard href="/develop/api-reference/widgets/st.text_input">
<Image pure alt="screenshot" src="/images/api/text_input.jpg" />
<h4>Text input</h4>
Display a single-line text input widget.
```python
name = st.text_input("First name")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.text_area">
<Image pure alt="screenshot" src="/images/api/text_area.jpg" />
<h4>Text area</h4>
Display a multi-line text input widget.
```python
text = st.text_area("Text to translate")
```
</RefCard>
<RefCard href="/develop/api-reference/chat/st.chat_input">
<Image pure alt="screenshot" src="/images/api/chat_input.jpg" />
<h4>Chat input</h4>
Display a chat input widget.
```python
prompt = st.chat_input("Say something")
if prompt:
st.write(f"The user has sent: {prompt}")
```
</RefCard>
</TileContainer>
## Other input elements
<TileContainer>
<RefCard href="/develop/api-reference/data/st.data_editor">
<Image pure alt="screenshot" src="/images/api/data_editor.jpg" />
<h4>Data editor</h4>
Display a data editor widget.
```python
edited = st.experimental_data_editor(df, num_rows="dynamic")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.file_uploader">
<Image pure alt="screenshot" src="/images/api/file_uploader.jpg" />
<h4>File uploader</h4>
Display a file uploader widget.
```python
data = st.file_uploader("Upload a CSV")
```
</RefCard>
<RefCard href="/develop/api-reference/widgets/st.camera_input">
<Image pure alt="screenshot" src="/images/api/camera_input.jpg" />
<h4>Camera input</h4>
Display a widget that allows users to upload images directly from a camera.
```python
image = st.camera_input("Take a picture")
```
</RefCard>
</TileContainer>
<ComponentSlider>
<ComponentCard href="https://github.com/okld/streamlit-elements">
<Image pure alt="screenshot" src="/images/api/components/elements.jpg" />
<h4>Streamlit Elements</h4>
Create a draggable and resizable dashboard in Streamlit. Created by [@okls](https://github.com/okls).
```python
from streamlit_elements import elements, mui, html
with elements("new_element"):
mui.Typography("Hello world")
```
</ComponentCard>
<ComponentCard href="https://github.com/gagan3012/streamlit-tags">
<Image pure alt="screenshot" src="/images/api/components/tags.jpg" />
<h4>Tags</h4>
Add tags to your Streamlit apps. Created by [@gagan3012](https://github.com/gagan3012).
```python
from streamlit_tags import st_tags
st_tags(label='# Enter Keywords:', text='Press enter to add more', value=['Zero', 'One', 'Two'],
suggestions=['five', 'six', 'seven', 'eight', 'nine', 'three', 'eleven', 'ten', 'four'], maxtags = 4, key='1')
```
</ComponentCard>
<ComponentCard href="https://github.com/Wirg/stqdm">
<Image pure alt="screenshot" src="/images/api/components/stqdm.jpg" />
<h4>Stqdm</h4>
The simplest way to handle a progress bar in streamlit app. Created by [@Wirg](https://github.com/Wirg).
```python
from stqdm import stqdm
for _ in stqdm(range(50)):
sleep(0.5)
```
</ComponentCard>
<ComponentCard href="https://github.com/innerdoc/streamlit-timeline">
<Image pure alt="screenshot" src="/images/api/components/timeline.jpg" />
<h4>Timeline</h4>
Display a Timeline in Streamlit apps using [TimelineJS](https://timeline.knightlab.com/). Created by [@innerdoc](https://github.com/innerdoc).
```python
from streamlit_timeline import timeline
with open('example.json', "r") as f:
timeline(f.read(), height=800)
```
</ComponentCard>
<ComponentCard href="https://github.com/blackary/streamlit-camera-input-live">
<Image pure alt="screenshot" src="/images/api/components/camera-live.jpg" />
<h4>Camera input live</h4>
Alternative for st.camera_input which returns the webcam images live. Created by [@blackary](https://github.com/blackary).
```python
from camera_input_live import camera_input_live
image = camera_input_live()
st.image(value)
```
</ComponentCard>
<ComponentCard href="https://github.com/okld/streamlit-ace">
<Image pure alt="screenshot" src="/images/api/components/ace.jpg" />
<h4>Streamlit Ace</h4>
Ace editor component for Streamlit. Created by [@okld](https://github.com/okld).
```python
from streamlit_ace import st_ace
content = st_ace()
content
```
</ComponentCard>
<ComponentCard href="https://github.com/AI-Yash/st-chat">
<Image pure alt="screenshot" src="/images/api/components/chat.jpg" />
<h4>Streamlit Chat</h4>
Streamlit Component for a Chatbot UI. Created by [@AI-Yash](https://github.com/AI-Yash).
```python
from streamlit_chat import message
message("My message")
message("Hello bot!", is_user=True) # align's the message to the right
```
</ComponentCard>
<ComponentCard href="https://github.com/victoryhb/streamlit-option-menu">
<Image pure alt="screenshot" src="/images/api/components/option-menu.jpg" />
<h4>Streamlit Option Menu</h4>
Select a single item from a list of options in a menu. Created by [@victoryhb](https://github.com/victoryhb).
```python
from streamlit_option_menu import option_menu
option_menu("Main Menu", ["Home", 'Settings'],
icons=['house', 'gear'], menu_icon="cast", default_index=1)
```
</ComponentCard>
<ComponentCard href="https://extras.streamlit.app/">
<Image pure alt="screenshot" src="/images/api/components/extras-toggle.jpg" />
<h4>Streamlit Extras</h4>
A library with useful Streamlit extras. Created by [@arnaudmiribel](https://github.com/arnaudmiribel/).
```python
from streamlit_extras.stoggle import stoggle
stoggle(
"Click me!", """🥷 Surprise! Here's some additional content""",)
```
</ComponentCard>
</ComponentSlider>