Skip to main content

Streamlit Avatar Stack

A selectable avatar stack built with Streamlit Components V2. It supports names, Material Symbols, remote images, data URIs, and local image paths.

Install

pip install streamlit-avatar-stack

For local development:

uv pip install -e .

Usage

import streamlit as st
from streamlit_avatar_stack import avatar_stack

avatars = [
    "Ada Lovelace",
    ":material/engineering:",
    "https://example.com/avatar.jpg",
    "images/grace.png",
]

selected = avatar_stack(avatars, key="people")
st.write(selected)

The component detects each avatar type automatically. Images are cropped to fill the circle, and invalid images display a fallback icon. Nothing is selected by default; clicking the selected avatar clears it.

API reference

avatar_stack(
    avatars,
    *,
    key,
    labels=None,
    return_index=True,
    default=None,
    bind=None,
    on_change=None,
    args=(),
    kwargs=None,
    size=48,
    display_max=None,
    horizontal_alignment="right",
    overlap_avatars=True,
    overlap=12,
    random_background=True,
)

Required arguments

  • avatars: A non-empty sequence of names, Material icon strings, image URLs, data URIs, or local image paths.
  • key: A non-empty, stable Streamlit component key.

Optional arguments

  • labels=None: Tooltip labels in the same order as avatars.
  • return_index=True: Return the selected index; when false, return its label.
  • default=None: Initially selected index.
  • bind=None: Use "query-params" for label-based URL binding.
  • on_change=None: Callback invoked when the selection changes.
  • args=(): Positional callback arguments.
  • kwargs=None: Keyword callback arguments.
  • size=48: Avatar diameter in pixels.
  • display_max=None: Maximum visible avatars before the +N control.
  • horizontal_alignment="right": Align the stack to "left" or "right".
  • overlap_avatars=True: Control whether regular avatars overlap.
  • overlap=12: Overlap distance in pixels.
  • random_background=True: Use varied avatar backgrounds; false uses the theme’s secondary background color.

Avatars wrap automatically. When collapsed, an off-page selection temporarily replaces the final visible avatar and returns to its original position when cleared.

Labels and URL binding

labels = ["Ada", "Engineering", "Grace", "Assistant"]

selected = avatar_stack(
    avatars,
    labels=labels,
    return_index=False,
    key="person",
    bind="query-params",
)

Query-parameter binding requires unique labels, return_index=False, and a key. It synchronizes the selected label in both directions.

Demo

uv run streamlit run main.py

The demo loads 25 records from data/avatars.json, including each avatar’s label, title, and department, and displays the selected record.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_avatar_stack-0.1.3.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

streamlit_avatar_stack-0.1.3-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_avatar_stack-0.1.3.tar.gz.

File metadata

  • Download URL: streamlit_avatar_stack-0.1.3.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for streamlit_avatar_stack-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7a051a36111d6db10bb85f3f5de70c08fae6b482c9cd9bedbfe777eef1e4b3bd
MD5 a355582a11a05e21a206642e58b5c94c
BLAKE2b-256 99dc0f29625967351a57aaa20d280a93d4c66345a31f0c0dfc3ed33dac86ae25

See more details on using hashes here.

File details

Details for the file streamlit_avatar_stack-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_avatar_stack-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 94a14ed6f496c91e57d783ec4518d963553e7179052b3afac79335079a005fed
MD5 b20f3249ac844c50cba62fe1dbd801a0
BLAKE2b-256 62768ab3cf871d42b7755e29d631066245c34c3a5f3fbc8ef72e7115cfc748ed

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page