How gabrieltempass/streamlit-navigation-bar works
Project Type and Purpose
• This is a full-stack component library for Streamlit: a Python package (“streamlit-navigation-bar”) that bundles a Vue/Vite front-end widget and exposes it via Streamlit’s component API.
• Purpose: Provide a customizable navigation bar widget in Streamlit apps, with examples demonstrating multipage setups.
High-Level Architecture
• User’s Browser: Renders the Streamlit UI including the navigation bar component (Vue app).
• Streamlit Server/Runtime: Runs user app code (the examples), hosts the component, and manages the WebSocket connection.
• Python Component Backend:
• streamlit_navigation_bar/__init__.py, __main__.py, match_navbar.py, errors.py – define the Streamlit component function st_navbar() and logic to match pages.
• templates/ and frontend assets: CSS templates and built JS/HTML from the Vue/Vite project.
• Front-End Widget (Vue/Vite):
• frontend/src containing App.vue, StNavbar.vue, Streamlit connection helpers.
• package.json, vite.config.ts orchestrate build, generating static assets.
• Examples Suite: Python scripts under examples/* show how to import and use st_navbar() in different Streamlit multipage structures.
• External Dependencies:
• Streamlit itself (1.33+) with component API.
• CSS :has pseudo‐class support.
• Optional external URLs (docs, community links).
a. Components
• User Browser (Client)
• Streamlit Server
• Python Package (streamlit_navigation_bar)
• Vue Front-End Assets
• Example App Code
• External Services (e.g., documentation links, PyPI)
b. Interactions & Data Flows
1. User loads example Streamlit app in browser.
2. Browser establishes WebSocket to Streamlit Server.
3. Example App calls st_navbar() → Streamlit component API loads the Vue widget.
4. Vue widget (StNavbar.vue) renders nav items; user clicks.
5. Vue captures click, sends event back via Streamlit’s component protocol.
6. Python backend (match_navbar.py) receives selection, returns updated page name.
7. Example App uses returned value to render appropriate Streamlit page.
c. Architectural Patterns
• Component-based UI (Vue) within a Python backend.
• Single Page App approach for the navigation bar.
• Streamlit’s Reactive model: front-end events trigger Python callbacks.
d. Key Technologies
• Python 3.8+, Streamlit ≥1.33 (component API)
• Vue.js + TypeScript + Vite (frontend build)
• CSS templates using :has pseudo-class
• Packaging via setup.py, wheel distribution
Detailed Elements to Capture
• streamlit_navigation_bar/frontend/src → Vue components (App.vue, StNavbar.vue)
• Build config files (package.json, vite.config.ts)
• Python entrypoints (__main__.py, __init__.py, match_navbar.py)
• Example folder hierarchy demonstrating multipage patterns
• CSS templates folder for style overrides