Streamlit component that allows you to do create a more flexible customisable streamlit sidebar
Project description
streamlit-custom-sidebar
Streamlit component that allows you to do buid a more flexible customizable sidebar that does not look buggy when rendered. Usually when we try to adjust the native streamlit sidebar it gets rendered after all the streamlit default settings are rendered. With this, your default settings are rendered when the page loads but it still uses streamlit's sidebar mative settings - css like its open and close animation and buttons.
Dependencies: Uses other custom components I created:
Installation instructions
pip install streamlit-custom-sidebar
# Pre-requisites
create `.streamlit/config.toml` directory where the main app.py file is located
in there, input
[ui]
hideSidebarNav=true
or
start streamlit app with
`streamlit run app.py --ui.hideSidebarNav=true`
Usage instructions
import streamlit as st
from streamlit_custom_sidebar import CustomSidebarDefault
import streamlit_float # recommended
# important to set page name as compoennt automatically looks for this in order to set current active tab - to demonstrate which page has currently been loaded
st.set_page_config(layout="wide", page_title="insert current page here")
streamlit_float.float_init()
data_ = [
{"index":0, "label":"Example", "page":"example", "href":"http://localhost:8501/"},
{"index":1, "label":"Page", "page":"page", "icon":"ri-logout-box-r-line", "href":"http://localhost:8501/page"}
]
if "currentPage" not in st.session_state: # required as component will be looking for this in session state to change page via `switch_page`
st.session_state["currentPage"] = data_[0]
else:
st.session_state["currentPage"] = data_[0]
with st.container():
defaultSidebar = CustomSidebarDefault(closeNavOnLoad=False, backgroundColor="brown", loadPageName="example", data=data_, LocalOrSessionStorage=1, serverRendering=False, webMedium="local")
defaultSidebar.load_custom_sidebar()
defaultSidebar.change_page()
streamlit_float.float_parent(css="top:-1000px;") # gets rid of the whitespace created from the iframes used to build the component - no big forehead.
# The above must be rendered atop every streamlit page
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for streamlit-custom-sidebar-0.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e77aa899ca60ca87ee6a914eea1f7bee1823ebd3a7691ebd02556fcf93a9813 |
|
MD5 | c5f6c480b5c7248cc9a9834a3c5d6700 |
|
BLAKE2b-256 | ab05b8081fb697ffbb6c8990ed462efe567109633f30f6a178554c02befb09e3 |
Close
Hashes for streamlit_custom_sidebar-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59be408945e93faa0457d346462b4c0f71e28d063ae53cff56f4d2d97888a101 |
|
MD5 | 53538f37428caf07130889ae7cadedd4 |
|
BLAKE2b-256 | 0e51e7cfc4f6e5b6d4bbc371d41b17e33cde4af226a25e87729e70db3c865524 |