st.segmented_control - Streamlit Docs
Show API reference for

Display a segmented control widget.

A segmented control widget is a linear set of segments where each of the passed options functions like a toggle button.

Examples

Example 1: Multi-select segmented control

Display a multi-select segmented control widget, and show the selection:

import streamlit as st

options = ["North", "East", "South", "West"]
selection = st.segmented_control(
    "Directions", options, selection_mode="multi"
)
st.markdown(f"Your selected options: {selection}.")

Example 2: Single-select segmented control with icons

Display a single-select segmented control widget with icons:

import streamlit as st

option_map = {
    0: ":material/add:",
    1: ":material/zoom_in:",
    2: ":material/zoom_out:",
    3: ":material/zoom_out_map:",
}
selection = st.segmented_control(
    "Tool",
    options=option_map.keys(),
    format_func=lambda option: option_map[option],
    selection_mode="single",
)
st.write(
    "Your selected option: "
    f"{None if selection is None else option_map[selection]}"
)
star

Tip

Want a new st.segmented_control 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.