Buttons
A button triggers an action when clicked. The button function returnsTrue 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: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: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.