Skip to main content

Streamlit component for a floating User Info panel anchored to the sidebar. Supports fixed float stick in sidebar, a collapsed avatar chip when the sidebar is hidden, usage stats (messages/tokens/cost), and compact layout.

Project description

st-user-info-panel

A polished Streamlit custom component for a floating User Info Panel anchored to the sidebar.
Supports fixed float stick in sidebar, collapsed chip (avatar initials) when the sidebar is collapsed, and usage stats (messages, tokens, cost).

PyPI version License: MIT

Repo: https://github.com/agustyawan-arif/st-user-info-panel


✨ Features

  • Floating panel that follows the sidebar width (portal) or sticky at the bottom of the sidebar (inside).
  • Collapsed chip: when the sidebar collapses, a small circular chip with initials appears;
  • Stats: Messages, Tokens, Cost with optional progress bars if monthly limits are set.
  • Compact mode for tighter sidebars.
  • Optional fields: Department, Work Location.
  • Uncontrolled (default) or Controlled expansion state.
  • Robust geometry handling for scrollable sidebars and animated collapse/expand.

📦 Install

Note: Starting from version 0.1.1, the minimum required Python version has been lowered to >=3.10 (previously >=3.11), providing broader compatibility!

pip install st-user-info-panel

Import name:

from st_user_info_panel import st_user_info_panel

🚀 Quickstart

import streamlit as st
from st_user_info_panel import st_user_info_panel

st.set_page_config(page_title="AI Chat Assistant Demo", layout="wide", initial_sidebar_state="expanded")

if "user_panel_expanded" not in st.session_state:
    st.session_state.user_panel_expanded = False

with st.sidebar:
    st.title("🤖 AI Assistant")
    st.subheader("Recent Conversations")
    for i in range(20):
        st.markdown(f"• Chat {i+1}")

    st.markdown("---")
    st.subheader("Settings")
    st.selectbox("Model", ["GPT-4", "Claude", "Gemini"])
    st.slider("Temperature", 0.0, 2.0, 0.7)

    result = st_user_info_panel(
        name="Sarah Johnson",
        job_title="Senior Data Scientist",
        email="sarah.johnson@techcorp.com",
        department="Data Platform",
        work_location="Jakarta",
        messages_count=340, monthly_messages_limit=500,
        tokens_this_month=3_200_000, monthly_tokens_limit=10_000_000,
        cost_usd=42.35, monthly_cost_limit=200.0,
        show_detailed_stats=True,
        compact=True,
        stats_style="rows",
        show_progress=False,
        side_padding_px=12,
        bottom_offset_px=16,
        controlled=False,
        expanded=st.session_state.user_panel_expanded,
        key="user-panel",
    )

    if result:
        evt = result.get("event")
        if evt == "toggle":
            st.session_state.user_panel_expanded = result["expanded"]
        elif evt == "logout":
            st.session_state.user_panel_expanded = False
            st.warning("Logout clicked")
        elif evt == "chip":
            pass

⚙️ API

st_user_info_panel(...) -> dict | None

Identity

Prop Type Default Notes
name str "John Doe" Used for initials
job_title str "Data Scientist"
email str "john.doe@company.com" Wraps for long values
avatar_color str "#FE5556" Any CSS color
department Optional[str] None Optional
work_location Optional[str] None Optional

Stats (neutral)

Prop Type Default Notes
messages_count int 0
monthly_messages_limit int 0 0 = unlimited
tokens_this_month int 0
monthly_tokens_limit int 0 0 = unlimited
cost_usd float 0.0
monthly_cost_limit float 0.0 0 = unlimited
show_detailed_stats bool True
show_progress bool True

Layout & Behavior

Prop Type Default Notes
info_grid_columns str "110px 1fr" Grid ratio for info card (e.g., "30% 70%" or "1fr 2fr")
color_mode Literal["auto","light","dark"] "auto" Force light/dark theme, or auto-detect Streamlit theme
side_padding_px int 12
bottom_offset_px int 16
border_radius_px int 12
compact bool False
stats_style Literal["rows","cards"] "rows" rows is compact
logout_label str "Logout" Text label for the logout button
logout_icon Optional[str] "🚪" Icon for logout button. Supports :material/icon_name:
logout_color Optional[str] None Custom button color. Defaults to Streamlit theme color

State control

Prop Type Default Notes
controlled bool False If True, follows expanded prop
expanded bool False
key Optional[str] None Stable key recommended

Return (events)

{
  "event": "toggle" | "logout" | "chip",
  "expanded": bool,
}

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

st_user_info_panel-0.1.5.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

st_user_info_panel-0.1.5-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file st_user_info_panel-0.1.5.tar.gz.

File metadata

  • Download URL: st_user_info_panel-0.1.5.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for st_user_info_panel-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0bc8e353a2ab313dff7279407f2302cfbd991edc5264b44fd3e7d33347cba939
MD5 f0dbd7f7c9695ffbf4ddabc29235b0cb
BLAKE2b-256 bc5aa0f9d06471084275d0b360e1d5bcb785dde58e8f099f5563a4279b2b52f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for st_user_info_panel-0.1.5.tar.gz:

Publisher: publish.yml on agustyawan-arif/st-user-info-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file st_user_info_panel-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for st_user_info_panel-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 04e042558e9aafb68647b43956768c8ab66e6c6128afcb975d3282044f5c34e3
MD5 87669616b1130bf2b319c37d442ff07c
BLAKE2b-256 add7a0cdc8c6fc92418d3166ab4f2bed103154bf7f59c43c9e65af556dd234d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for st_user_info_panel-0.1.5-py3-none-any.whl:

Publisher: publish.yml on agustyawan-arif/st-user-info-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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