A Streamlit custom component for segmented button controls with rich text support
Project description
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.
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
st_segmented_buttons-0.1.0.tar.gz
(401.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters