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 asavatars.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+Ncontrol.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
Metadata
Release files for streamlit-avatar-stack 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| streamlit_avatar_stack-0.1.3.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| streamlit_avatar_stack-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / streamlit_avatar_stack-0.1.3.tar.gz
| Download URL | streamlit_avatar_stack-0.1.3.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a051a36111d6db10bb85f3f5de70c08fae6b482c9cd9bedbfe777eef1e4b3bd
|
|
BLAKE2b-256 checksum How to use checksums |
99dc0f29625967351a57aaa20d280a93d4c66345a31f0c0dfc3ed33dac86ae25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / streamlit_avatar_stack-0.1.3-py3-none-any.whl
| Download URL | streamlit_avatar_stack-0.1.3-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94a14ed6f496c91e57d783ec4518d963553e7179052b3afac79335079a005fed
|
|
BLAKE2b-256 checksum How to use checksums |
62768ab3cf871d42b7755e29d631066245c34c3a5f3fbc8ef72e7115cfc748ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|