Skip to main content

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 str or None
  • Multi-select: Returns list of selected values as List[str] or []

License

MIT License - see LICENSE file for details.

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

st_segmented_buttons-0.1.0-py3-none-any.whl (403.8 kB view details)

Uploaded Python 3

File details

Details for the file st_segmented_buttons-0.1.0.tar.gz.

File metadata

  • Download URL: st_segmented_buttons-0.1.0.tar.gz
  • Upload date:
  • Size: 401.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for st_segmented_buttons-0.1.0.tar.gz
Algorithm Hash digest
SHA256 288b63f0301fd2c1af115e778349768540c636f0a1405d45e053a53b3540a041
MD5 cd105d543785c67b35c37ca4308e576d
BLAKE2b-256 5dadd74930fe3a1bd36b2e61b135bf8aa69010024b76fd62615ae216225afde7

See more details on using hashes here.

File details

Details for the file st_segmented_buttons-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for st_segmented_buttons-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fd41aac37cef5a381e6fac2929c2795e51d7bfe30878199352f05237225fd54
MD5 6fbb42cfb8ff9d030ca13c2f3965fa3f
BLAKE2b-256 3435c9f0c1495a21a2a4b7ba77f802fdb10ee61a4b8f6f4a50bddf3a5e3aef5e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page