Skip to main content
Widgets are the interactive building blocks of every Streamlit app. They let users provide data, make selections, upload files, and trigger actions — and because Streamlit reruns your script on every interaction, the rest of your app responds to widget values automatically. Each widget function returns the current value chosen by the user, which you can store in a variable and use anywhere in your Python logic. This page covers every major widget type with ready-to-use code examples.

Buttons

A button triggers an action when clicked. The button function returns True for the single rerun that follows a click, then False again on all subsequent reruns.

Text Input and Text Area

Use text fields for free-form user input. text_input is for short, single-line values; text_area is for longer, multi-line content.

Selectbox, Radio, and Checkbox

These widgets handle single-choice and toggle selections:

Multiselect

Allow users to choose multiple values from a list:

Number Input and Slider

For numeric values, choose between a text field with increment/decrement arrows or a draggable slider:
Passing a tuple as the value argument to st.slider creates a range slider with two handles, perfect for price or date range filters.

File Uploader

Let users upload files from their local machine. The returned object behaves like a file handle you can pass directly to Pandas or other libraries:
You can accept multiple file types simultaneously:

Date and Time Inputs

Use date and time pickers for scheduling or filtering by date:

Combining Widgets

In a real app, you’ll combine multiple widgets and use their values together. Here’s a simple employee filter:
All widget values are re-evaluated on every script rerun. If you need to persist a value across reruns (e.g., a counter or authenticated user), use st.session_state — covered in the Building Apps chapter.