Skip to main content

Streamlit component that creates a selectable list of icons with labels.

Project description

streamlit-select-icons

A Streamlit custom component that creates a selectable grid of labeled icons with flexible layout options.

Features

  • Grid-based layout system (rows/columns)
  • Multi/single selection modes
  • Responsive card sizing
  • Per-item custom styling (colors)
  • Bold selected labels
  • Configurable component dimensions
  • Row/column orientations with scrolling
  • No icon support (display items without images)
  • Alternative text display (show text/emoji instead of icons)

Installation

pip install streamlit-select-icons

Usage

import streamlit as st
from streamlit_select_icons import select_icons

# Define your items
items = {
    "home": {
        "label": "Home", 
        "icon": "static/home-icon.png",  # Will resolve to /app/static/home-icon.png
        "properties": {"category": "navigation"}
    },
    "search": {
        "label": "Search", 
        "icon": "static/search-icon.png",  # Will resolve to /app/static/search-icon.png
        "properties": {"category": "action"}
    },
    "profile": {
        "label": "Profile", 
        "icon": "static/profile-icon.png",  # Will resolve to /app/static/profile-icon.png
        "properties": {"category": "user"}
    },
    "status": {
        "label": "Active", 
        "icon": None,  # No icon - will show placeholder
        "properties": {"category": "status"}
    },
    "priority": {
        "label": "High Priority", 
        "icon": None,  # No icon
        "alt_text": "⚡",  # Show emoji instead
        "properties": {"category": "priority"}
    },
}

# Create the icon selector
result = select_icons(
    items=items,
    multi_select=True,           # Allow multiple selections
    layout="column",             # or "row"
    columns=2,                   # Number of columns in grid
    width=300,                   # Component width
    height=200,                  # Component height
    size=80,                     # Individual card size
    bold_selected=True,          # Bold labels when selected
    key="icon_selector"
)

if result:
    st.write("Selected items:", result["selected_items"])
    st.write("All items:", result["items"])

Icon Configuration

With Icons

"item_id": {
    "label": "Item Label",
    "icon": "static/icon.png",  # Path to icon image
    "properties": {...}
}

Without Icons

"item_id": {
    "label": "Item Label",
    "icon": None,  # No icon - label text fills the icon area
    "properties": {...}
}

With Alternative Text

"item_id": {
    "label": "Item Label",
    "icon": None,  # No icon
    "alt_text": "📝",  # Text/emoji to display instead (larger than label)
    "properties": {...}
}

Note: When both icon and alt_text are None, the component completely omits the icon area, displaying only the label text. This creates a cleaner, more focused appearance for text-only items.

Static Files

The component automatically resolves icon paths that start with static/ to Streamlit's /app/static/ folder. This means:

  • "static/icon.png"/app/static/icon.png
  • "static/my-icon.svg"/app/static/my-icon.svg

Important: Place your icon images in your Streamlit app's static/ folder for this to work correctly.

Parameters

  • items: Dictionary of items with id keys and item data
    • label: Display text for the item
    • icon: Path to icon image (can be None for no icon)
    • alt_text: Text/emoji to display when icon is None (optional)
    • properties: Additional metadata (optional)
  • selected_items: List of pre-selected item IDs
  • multi_select: Enable multiple selection (default: True)
  • layout: "column" or "row" layout orientation
  • columns: Number of columns (column layout)
  • rows: Number of rows (row layout)
  • width: Component container width in pixels
  • height: Component container height in pixels
  • size: Individual card size in pixels (default: 96)
  • item_style: Per-item custom colors and styling
  • bold_selected: Make selected labels bold (default: False)
  • key: Unique component key

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

streamlit_select_icons-0.1.0.tar.gz (128.8 kB view details)

Uploaded Source

Built Distribution

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

streamlit_select_icons-0.1.0-py3-none-any.whl (127.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_select_icons-0.1.0.tar.gz
  • Upload date:
  • Size: 128.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for streamlit_select_icons-0.1.0.tar.gz
Algorithm Hash digest
SHA256 118df7ce94c6d07d4476026996adb76000f917534b8382997b13f3eb1cd110de
MD5 359d8261c54ce2404aaaa85dbfe93695
BLAKE2b-256 305df696e1d263dc44bcfa600868330f44745308df5617b27ad3bc7a46567ea2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_select_icons-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bfc69eb023c836ed1114cf446ed2b977fcef8b70bafebb86571aa28c5c40bd6
MD5 bed431ea7263077e638d6203b01cf1af
BLAKE2b-256 f1c0233f0ed10b8a2beccb4d985428c079ca7d37e215e123544c38b2a8578b89

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