📘 Introduction

Creating interactive web apps with Streamlit is incredibly easy — even if you're not a front-end developer. Once you've mastered the basics, Streamlit’s widget system becomes your playground. These widgets let users interact with your data and models in real time.

In this post, you'll explore 10 must-know Streamlit widgets with simple usage examples to bring your data apps to life. Let’s dive in! 💡

✅ Prerequisites

Before we begin, make sure you’ve got Streamlit installed.

☑️ Python 3.8+ installed
☑️ Streamlit installed (pip install streamlit)


🧰1️⃣ st.button()

Buttons are perfect for triggering actions like data reloads or model predictions.

if st.button("Click Me!"):
    st.success("You clicked the button 🚀")
📝 Use case: Start an operation like retraining a model or refreshing a dataset.

🧮2️⃣ st.slider()

Sliders let users choose numeric values or ranges intuitively.

value = st.slider("Pick a number", 0, 100, 50)
st.write(f"You selected: {value}")
🎯 Use case: Select the number of data points or set a threshold value.

📅3️⃣ st.date_input()

Collect dates for filtering data or selecting event timelines.

date = st.date_input("Select a date")
st.write(f"Date chosen: {date}")
📆 Use case: Filter data by a selected date or set deadlines.

📍4️⃣ st.selectbox()

Pick one option from a dropdown list.

option = st.selectbox("Choose a category", ["Sales", "Marketing", "Finance"])
st.write(f"Selected: {option}")
📊 Use case: Choose between different KPIs or datasets.

🔢5️⃣ st.number_input()

Input numbers directly with optional min, max, and step.

num = st.number_input("Enter a value", min_value=0.0, max_value=100.0, step=1.0)
st.write(f"Value entered: {num}")
💼 Use case: Input learning rate, price, or any continuous parameter.

🎯6️⃣ st.radio()

Display options as radio buttons.

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In