st-segmented-buttons
A customizable segmented button component for Streamlit applications. Create button groups with rich text, icons, and styling options.
Installation
pip install st-segmented-buttons
Quick start
import streamlit as st
from st_segmented_buttons import segmented_buttons
# Simple example
selection = segmented_buttons(
["Option A", "Option B", "Option C"],
default="Option A",
key="simple_buttons"
)
if selection:
st.write(f"You selected: {selection}")
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
buttons |
List[Union[str, Dict]] |
Required | Button definitions |
default |
Union[str, List[str]] |
None |
Default selection(s) |
multiselect |
bool |
False |
Enable multiple selection |
color |
str |
"#484853" |
Text color (unselected) |
background_color |
str |
"#ffffff" |
Background color (unselected) |
selected_color |
str |
"#106a6c" |
Text color (selected) |
selected_background_color |
str |
"#e9f1f0" |
Background color (selected) |
border_radius |
str |
"6px" |
Border radius |
border_width |
str |
"1px" |
Border width |
border_color |
str |
"#ebebeb" |
Border color (unselected) |
selected_border_color |
str |
"#106a6c" |
Border color (selected) |
shadow |
str |
"none" |
Box shadow CSS |
height |
str |
"40px" |
Button height |
font_size |
str |
"14px" |
Font size |
gap |
str |
"8px" |
Gap between buttons |
auto_stretch |
bool |
False |
Stretch to fill width |
key |
str |
None |
Streamlit component key |
Button dictionary format
When using dictionaries for buttons:
{
"label": "Display Text", # Required: HTML string
"value": "return_value", # Required: Return value
"icon": "🎯", # Optional: Icon/emoji
"disabled": False # Optional: Disable button
}
Return values
- Single select: Returns selected value as
strorNone - Multi-select: Returns list of selected values as
List[str]or[]
License
MIT License - see LICENSE file for details.
Release files for st-segmented-buttons 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| st_segmented_buttons-0.1.0.tar.gz | 401.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| st_segmented_buttons-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 805.1 kB