| | import streamlit as st |
| | from streamlit_option_menu import option_menu |
| |
|
| | |
| | EXAMPLE_NO = 2 |
| |
|
| |
|
| | def streamlit_menu(example=1): |
| | if example == 1: |
| | |
| | with st.sidebar: |
| | selected = option_menu( |
| | menu_title="Main Menu", |
| | options=["Home", "Projects", "Contact"], |
| | icons=["house", "book", "envelope"], |
| | menu_icon="cast", |
| | default_index=0, |
| | ) |
| | return selected |
| |
|
| | if example == 2: |
| | |
| | selected = option_menu( |
| | menu_title=None, |
| | options=["Home", "Projects", "Contact"], |
| | icons=["house", "book", "envelope"], |
| | menu_icon="cast", |
| | default_index=0, |
| | orientation="horizontal", |
| | ) |
| | return selected |
| |
|
| | if example == 3: |
| | |
| | selected = option_menu( |
| | menu_title=None, |
| | options=["Home", "Projects", "Contact"], |
| | icons=["house", "book", "envelope"], |
| | menu_icon="cast", |
| | default_index=0, |
| | orientation="horizontal", |
| | styles={ |
| | "container": {"padding": "0!important", "background-color": "#fafafa"}, |
| | "icon": {"color": "orange", "font-size": "25px"}, |
| | "nav-link": { |
| | "font-size": "25px", |
| | "text-align": "left", |
| | "margin": "0px", |
| | "--hover-color": "#eee", |
| | }, |
| | "nav-link-selected": {"background-color": "green"}, |
| | }, |
| | ) |
| | return selected |
| |
|
| |
|
| | selected = streamlit_menu(example=EXAMPLE_NO) |
| |
|
| | if selected == "Home": |
| | st.title(f"You have selected {selected}") |
| | if selected == "Projects": |
| | st.title(f"You have selected {selected}") |
| | if selected == "Contact": |
| | st.title(f"You have selected {selected}") |