Registry / web-framework / streamlit-avatar

streamlit-avatar

JSON →
library0.1.3pypypiunverified

streamlit-avatar is a Streamlit component designed to easily display avatar icons within Streamlit applications. It supports showing avatars from image URLs or displaying text/initials. The current version is 0.1.3, and it generally follows the Streamlit component release cycle, with updates as needed for compatibility or new features.

pip install streamlit-avatar
INSTALL
IMPORT
SIG · STREAMLIT-AVATAR
S
streamlit-avatar
web-frameworkpythonv0.1.3
Install
15.3s avg
Import
Disk
436MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 448.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 15.3s · import 0.000s · 417MB
436MB installed
● package 436MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

st_avatar
from streamlit_avatar import st_avatar
from streamlit import st_avatar
The `st_avatar` function is part of the `streamlit_avatar` library, not directly from the core `streamlit` library.

This example demonstrates how to display both an image-based avatar from a URL and a text-based avatar (e.g., initials) using the `streamlit_avatar` component. It showcases setting size, border styles, and click actions.

import streamlit as st from streamlit_avatar import st_avatar st.set_page_config(layout="wide") st.title("Streamlit Avatar Example") # Example 1: Image avatar from a URL st.header("1. Image Avatar") st.markdown("Displays an image from a URL. Click to open GitHub.") st_avatar( url="https://avatars.githubusercontent.com/u/84214537?v=4", size=80, border_radius=50, border_color="#007BFF", border_hover_color="#0056B3", open_url_on_click="https://github.com/ppspps824" ) # Example 2: Text avatar (initials) st.header("2. Text Avatar (Initials)") st.markdown("Displays text (e.g., initials) by setting `is_image=False`.") st_avatar( url="SA", # The text to display size=60, is_image=False, title_font_size=24, title_color="#FFF", border_radius=10, border_color="#28A745", border_hover_color="#218838" ) st.write("---") st.write("Avatars demonstrated above.")
Debug
Known issues
gotchaThe `is_image` parameter dictates whether the `url` content is treated as an image source or raw text. If `is_image=False`, the value of `url` is displayed as text directly, not interpreted as a URL to fetch a text-generated image.
fix
For text avatars (e.g., initials), set `is_image=False` and pass the desired text (e.g., 'JD') directly to the `url` parameter, rather than a URL that generates an image from text.
affects: 0.1.0+
gotchaLike all Streamlit components, `streamlit-avatar` must be run within a Streamlit application using `streamlit run your_app.py`. It will not render correctly if executed as a standard Python script.
fix
Always use `streamlit run <your_script_name>.py` from your terminal to execute Streamlit applications that use this component.
affects: All versions
gotchaOnly specific styling parameters are exposed (size, border_radius, colors, font sizes). Custom CSS beyond these parameters is not directly supported by the component and may require using Streamlit's `st.markdown(unsafe_allow_html=True)` to inject broader styling rules, which can be more complex.
fix
Utilize the provided parameters for styling. For highly custom styles, explore Streamlit's `st.markdown(unsafe_allow_html=True)` with caution to target specific HTML elements rendered by the component, or consider contributing to the component's styling options.
affects: All versions
Upgrade
Version history
0.1.3latest on PyPI · released Jun 3, 2024
Audit
Dependencies
streamlitrequiredRequired to run Streamlit applications and components.
Agent activity
9 hits · last 30 days
node
8
Resources
streamlit-avatar — pip install streamlit-avatar · libregistry