streamlit-option-menu is a simple Streamlit component that allows users to select a single item from a list of options in a menu.
Project description
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 is similar in function to st.selectbox(), except that:
- It uses a simple static list to display the options instead of a dropdown
- It has configurable icons for each option item and the menu title
It is built on [streamlit-component-template-vue](https://github.com/andfanilo/streamlit-component-template-vue), styled with [Bootstrap](https://getbootstrap.com/) and with icons from [bootstrap-icons](https://icons.getbootstrap.com/)
## Installation
```
pip install streamlit-option-menu
```
## Parameters
The `option_menu` function accepts the following parameters:
- menu_title (required): the title of the menu; pass None to hide the title
- options (required): list of (string) options to display in the menu; set an option to "---" if you want to insert a section separator
- default_index (optional, default=0): the index of the selected option by default
- menu_icon (optional, default="menu-up"): name of the [bootstrap-icon](https://icons.getbootstrap.com/) to be used for the menu title
- icons (optional, default=["caret-right"]): list of [bootstrap-icon](https://icons.getbootstrap.com/) names to be used for each option; its length should be equal to the length of options
- orientation (optional, default="vertical"): "vertical" or "horizontal"; whether to display the menu vertically or horizontally
The function returns the (string) option currently selected
## Example
```
import streamlit as st
from streamlit_option_menu import option_menu
with st.sidebar:
selected = option_menu("Main Menu", ["Home", 'Settings'],
icons=['house', 'gear'], menu_icon="cast", default_index=1)
selected
# horizontal Menu
selected2 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
icons=['house', 'cloud-upload', "list-task", 'gear'],
menu_icon="cast", default_index=0, orientation="horizontal")
selected2
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
streamlit-option-menu-0.2.8.tar.gz
(706.4 kB
view hashes)
Built Distribution
Close
Hashes for streamlit-option-menu-0.2.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e2f64346f561fdf8f83eb3f26a2ec5019ece94b6d5c3644be5fdadf08a205af |
|
MD5 | 668ec8f06f5f2a913c91c0f5a25a982b |
|
BLAKE2b-256 | d893885e93d4429862a5de4240f6b1fbf444595528b816fa330f0693b2146c33 |
Close
Hashes for streamlit_option_menu-0.2.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eee3db60b4e6d03903d73a61bef4984248e584302370f0d5d356cb0d181cfc52 |
|
MD5 | ce27857d60492912778f9fd98d2bdebd |
|
BLAKE2b-256 | b974445ccc81f927bc4b05af29674553888f32b5730ddf813ef383e7a9ff01f9 |