st.slider - Streamlit Docs
Show API reference for

Display a slider widget.

This supports int, float, date, time, and datetime types.

This also allows you to render a range slider by passing a two-element tuple or list as the value.

The difference between st.slider and st.select_slider is that slider only accepts numerical or date/time data and takes a range as input, while select_slider accepts any datatype and takes an iterable set of options.

Note

Integer values exceeding +/- (1<<53) - 1 cannot be accurately stored or returned by the widget due to serialization constraints between the Python server and JavaScript client. You must handle such numbers as floats, leading to a loss in precision.

The same constraint bounds date and datetime values, which are serialized as microseconds since the epoch: only values from 1684-07-29 to 2255-06-04 can be represented exactly. Streamlit raises an error for a bound outside that range rather than silently shifting it.

Examples

import streamlit as st

age = st.slider("How old are you?", 0, 130, 25)
st.write("I'm ", age, "years old")

And here's an example of a range slider:

import streamlit as st

values = st.slider("Select a range of values", 0.0, 100.0, (25.0, 75.0))
st.write("Values:", values)

This is a range time slider:

import streamlit as st
from datetime import time

appointment = st.slider(
    "Schedule your appointment:", value=(time(11, 30), time(12, 45))
)
st.write("You're scheduled for:", appointment)

Finally, a datetime slider:

import streamlit as st
from datetime import datetime

start_time = st.slider(
    "When do you start?",
    value=datetime(2020, 1, 1, 9, 30),
    format="MM/DD/YY - hh:mm",
)
st.write("Start time:", start_time)

Check out our video on how to use one of Streamlit's core functions, the slider!

In the video below, we'll take it a step further and make a double-ended slider.

star

Tip

Want a new st.slider feature or found a bug? Browse open issues and react with a 👍 on the initial post of the ones that matter to you. Your votes help us prioritize what to work on next.

forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.