Registry / web-framework / extra-streamlit-components

extra-streamlit-components

JSON →
library0.1.81pypypi✓ verified 23d ago

Extra Streamlit Components is a Python library that provides a collection of complex or natively unavailable components to enhance Streamlit applications. It aims to offer advanced UI elements such as a Router for multi-page apps, a Cookie Manager for browser interaction, and a TabBar. The library is currently at version 0.1.81 and receives updates periodically.

pip install extra-streamlit-components
INSTALL
IMPORT
SIG · EXTRA-STREAMLIT-CO
E
extra-streamlit-components
web-frameworkpythonv0.1.81
Install
15.7s avg
Import
1557ms
Disk
451MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.81 · 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.95 runs
installs and imports cleanly · install 0.0s · import 1.966s · 467.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 15.7s · import 1.148s · 430MB
451MB installed
● package 451MB
Code
Verified usage

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

stx
import extra_streamlit_components as stx
Router
stx.Router(...)
CookieManager
stx.CookieManager()
TabBarItemData
stx.TabBarItemData(...)

This quickstart demonstrates the usage of the `TabBar` component to create a multi-tab interface in a Streamlit application. It defines three tabs and displays content based on the user's selection.

import streamlit as st import extra_streamlit_components as stx st.set_page_config(layout="centered", page_title="Extra Streamlit Components Demo") st.title("Extra Streamlit Components Demo") # Example using TabBar component chosen_id = stx.tab_bar( data=[ stx.TabBarItemData(id="tab1", title="Tab One", description="First tab content"), stx.TabBarItemData(id="tab2", title="Tab Two", description="Second tab content"), stx.TabBarItemData(id="tab3", title="Tab Three", description="Third tab content"), ], default="tab1", key="tab_bar_example" ) if chosen_id == "tab1": st.write("You are on Tab One!") elif chosen_id == "tab2": st.write("You are on Tab Two!") elif chosen_id == "tab3": st.write("You are on Tab Three!")
Debug
Known issues
gotchaThe `Router` component should always be initialized using `@st.cache_resource` to prevent re-initialization issues during app reruns, which can lead to unexpected routing behavior.
fix
Decorate your `init_router` function with `@st.cache_resource(hash_funcs={"_thread.RLock": lambda _: None})`.
affects: All versions
gotchaThe `CookieManager` component may experience issues when deployed on platforms like Streamlit Community Cloud or Cloud Run, often related to asynchronous behavior or component loading timeouts. This can result in cookies not being set or retrieved correctly.
fix
Check for updated versions of `extra-streamlit-components` and Streamlit. Some users have reported manual deployment (not via CI/CD) or specific Streamlit versions (e.g., 1.32.0 improved custom component handling) mitigating issues. Debugging browser console logs may provide further insight. (See GitHub Issues #6, #67, Streamlit forum discussions)
affects: All versions, especially 0.1.71 and above (due to CSS issues).
gotchaThe internal `_remove_extra_spacing()` method, often used by components like `CookieManager`, can apply aggressive CSS that hides or interferes with other Streamlit components on the page. This is due to broad CSS selectors.
fix
If encountering this, consider pinning to a version prior to 0.1.71 if feasible for your project, or explore custom CSS overrides in your Streamlit app to counteract the conflicting styles.
affects: Versions 0.1.71 and above.
gotchaThe `CookieManager` operates on browser cookies. In shared domains like `share.streamlit.io`, other web developers may have access to cookies you set. This is a browser security model consideration, not a bug in the component, but developers must be aware of it for sensitive data.
fix
Avoid storing sensitive user data directly in browser cookies when deploying on shared domains. Use server-side sessions or more secure authentication mechanisms for critical information.
affects: All versions.
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'extra_streamlit_components'
The `extra-streamlit-components` library or a specific submodule was not installed, or the Python environment running the Streamlit app does not have it accessible.
fix
Ensure the library is correctly installed in your active Python environment using `pip install extra-streamlit-components`. If using a virtual environment, activate it first.
Your app is having trouble loading the extra_streamlit_components.CookieManager.cookie_manager component.
This error occurs when the Streamlit frontend component for the CookieManager fails to load, often due to deployment environment issues, network restrictions (like Content Security Policy), or asynchronous loading problems on platforms like Streamlit Community Cloud or Cloud Run.
fix
Check for updated versions of `extra-streamlit-components` and Streamlit, as newer versions may have improved custom component handling. Debug browser console logs for more insights. Manual deployment or specific Streamlit versions (e.g., 1.32.0 improved custom component handling) might mitigate the issue.
'NoneType' object has no attribute "get"
This typically happens with `CookieManager` when `cookie_manager.get()` is called before the component has fully initialized and fetched the cookies, making `self.cookies` (or the underlying cookie object) `None` at the time of access.
fix
Introduce a mechanism to ensure the `CookieManager` is fully initialized and its internal cookie state is populated before attempting to `get` or `set` cookies. Using `st.session_state` to store the manager and check its readiness, or adding small `time.sleep()` delays in specific contexts, can help. The `CookieManager` constructor can also trigger a rerun, so managing state carefully is crucial.
The `Router` component should always be initialized using `@st.cache_resource` to prevent re-initialization issues during app reruns, which can lead to unexpected routing behavior.
Initializing the `Router` object without the `@st.cache_resource` decorator causes it to be re-initialized on every Streamlit rerun, leading to inconsistent state, lost routing information, or unexpected page navigation.
fix
Decorate your `init_router` function with `@st.cache_resource(hash_funcs={'_thread.RLock': lambda _: None})` to ensure the Router is initialized only once and its state persists across app reruns.
Upgrade
Version history
0.1.81latest on PyPI · released Aug 17, 2025
Audit
Dependencies
streamlitrequiredCore dependency as it's a Streamlit component library.
Agent activity
11 hits · last 30 days
node
10
Resources
extra-streamlit-components — pip install extra-streamlit-components · libregistry