Skip to main content

Sidebar Menu custom component for Streamlit

Project description

Streamlit - Sidemenu

A streamlit component to implement collapsible menu on st_sidebar. Currently only child level, does not support grand-child level or lower level descendents.

Installation

pip install streamlit-sidemenu

Usage

Refer to this file for example usage.

Custom Styling

You can customize the menu styling from the example below (which is the default styling). Pass the customized style into the component styles argument.

styles = """
body {
  margin: 0;
}

#app {
  margin: 0;
}

/* Fixed sidenav, full height */
.sidenav {
  font-family: Arial;
  height: 100%;
  width: 100%;
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  background-color: #111;
  overflow-x: hidden;
  /* padding-top: 20px; */
}

/* Style the sidenav links and the dropdown button */
.sidenav a, .dropdown-btn {
  padding: 6px 8px 6px 16px;
  text-decoration: none;
  font-size: 20px;
  color: #818181;
  display: block;
  border: none;
  background: none;
  width:100%;
  text-align: left;
  cursor: pointer;
  outline: none;
}

/* On mouse-over */
.sidenav a:hover, .dropdown-btn:hover {
  color: #f1f1f1;
}

/* Main content */
.main {
  margin-left: 200px; /* Same as the width of the sidenav */
  font-size: 20px; /* Increased text to enable scrolling */
  padding: 0px 10px;
}

/* Add an active class to the active dropdown button */
.sidenav a.selected {
  background-color: green;
  color: white;
}

/* Dropdown container (hidden by default). Optional: add a lighter background color and some left padding to change the design of the dropdown content */
.dropdown-container {
  display: none;
  background-color: #262626;
  padding-left: 8px;
}

/* Optional: Style the caret down icon */
.fa-caret-down {
  float: right;
  padding-right: 8px;
}
"""

.pypirc File

Place the file in $HOME / ~ directory

[distutils]
index-servers =
  pypi
  testpypi

[pypi]
username = __token__
password = pypi-xxx

[testpypi]
username = __token__
password = pypi-yyy
repository = https://test.pypi.org/legacy/

Frontend Notes

npm 6.x

cd <component_name_vanilla>
npm init vite@latest frontend --template vanilla
cd <component_name_vue>
npm init vite@latest frontend --template vue

npm 7+

cd <component_name>
npm init vite@latest frontend -- --template vanilla
cd frontend
npm i streamlit-component-lib

take note of vite.config.js

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

streamlit_sidemenu-0.0.4.tar.gz (62.6 kB view details)

Uploaded Source

Built Distribution

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

streamlit_sidemenu-0.0.4-py3-none-any.whl (67.5 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_sidemenu-0.0.4.tar.gz.

File metadata

  • Download URL: streamlit_sidemenu-0.0.4.tar.gz
  • Upload date:
  • Size: 62.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

File hashes

Hashes for streamlit_sidemenu-0.0.4.tar.gz
Algorithm Hash digest
SHA256 6bd1e65e26cddfa511f90bd4aa054a16164ffc42af509ea69ffc545108b95d55
MD5 44855a4585f2ba7117007d840bd5f64a
BLAKE2b-256 eb2ebc403b73e4b09ab5215ee40fe06445052b2aa4a69b2ec4624279e17e8797

See more details on using hashes here.

File details

Details for the file streamlit_sidemenu-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: streamlit_sidemenu-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 67.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

File hashes

Hashes for streamlit_sidemenu-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e96e031d841fb185b430cc373982d02514ae4babd1895ec58b4aab9493e0a92b
MD5 c89cf74a6e6881bc1a7fd0138668ff5b
BLAKE2b-256 851cc4a0684a8ddec49ba49bac54f301506dc699e737694c6b454aa29d4df13e

See more details on using hashes here.

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