© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
S. RaghavendraBeginner's Guide to Streamlit with Python https://doi.org/10.1007/978-1-4842-8983-9_5

5. Buttons and Sliders

Sujay Raghavendra1  
(1)
Dharwad, Karnataka, India
 

In this chapter, we will discuss how to create different types of buttons. These buttons are a medium for interaction between the user and the application. Let’s start by creating these buttons one by one.

Buttons

A button is created by using the following syntax:
st.button('button_name')
Let’s create a button by using this syntax ; see Listing 5-1.
import streamlit as st
st.title('Creating a Button')
# Defining a Button
button = st.button('Click Here')
if button:
    st.write('You have clicked ...

Get Beginner's Guide to Streamlit with Python: Build Web-Based Data and Machine Learning Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.