Streamlit Option Menu

0.4.0 · active · verified Tue Apr 14

streamlit-option-menu is a simple Streamlit component that allows users to select a single item from a list of options in a menu. It provides a static list of options with configurable icons and extensive CSS styling capabilities, offering an alternative to `st.selectbox()` for navigation. The current stable version is 0.4.0, with regular updates and community engagement.

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a vertical navigation menu in the sidebar using `streamlit-option-menu`, displaying different content based on the user's selection.

import streamlit as st
from streamlit_option_menu import option_menu

st.set_page_config(layout="wide")

with st.sidebar:
    selected = option_menu(
        menu_title="Main Menu",  # required
        options=["Home", "Projects", "Contact"],  # required
        icons=["house", "code-slash", "envelope"],  # optional
        menu_icon="cast",  # optional
        default_index=0,  # optional
        orientation="vertical"
    )

if selected == "Home":
    st.title(f"You selected: {selected}")
    st.write("Welcome to the Home page!")
elif selected == "Projects":
    st.title(f"You selected: {selected}")
    st.write("Here are my projects.")
elif selected == "Contact":
    st.title(f"You selected: {selected}")
    st.write("Contact me here.")

view raw JSON →