Streamlit Avatar

0.1.3 · active · verified Fri Apr 17

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.

Common errors

Warnings

Install

Imports

Quickstart

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.")

view raw JSON →