Skip to main content

Streamlit-Pages

Releases Build Status Python Versions Streamlit versions License Ruff

Streamlit App

Author: @blackary

Code: https://github.com/blackary/st_pages

Installation

pip install st-pages

See it in action

Basic example: https://st-pages.streamlit.app/

Example with sections: https://st-pages-sections.streamlit.app/

Why st-pages?

Previously, st-pages allowed for a much more customizable and flexible declaration of pages in a Streamlit app, and was independent of the actual filenames of the python files in your project.

As of 1.0.0, st-pages is now a tiny wrapper that provides an easy method for defining the pages in your app in a toml file, as well as a few utility methods to let you add the current page's title to all pages, etc.

You are welcome to continue to use older versions of this package, but most of the old use-cases are now easy to do with native streamlit, so I would recommend checking out the documentation for more information.

How to use

Declare pages inside of a toml file

Contents of .streamlit/pages.toml

[[pages]]
path = "page1.py"
name = "Home"
icon = "🏠"

[[pages]]
path = "other_pages/page2.py"
name = "Page 2"
icon = ":books:"
url_path = "my_books" # You can override the default url path for a page

Example with sections, .stremalit/pages_sections.toml:

[[pages]]
path = "page1.py"
name = "Home"
icon = "🏠"

[[pages]]
path = "other_pages/page2.py"
name = "Page 2"
icon = ":books:"

[[pages]]
name = "My section"
icon = "🎈️"
is_section = true

# Pages after an `is_section = true` will be indented
[[pages]]
name = "Another page"
icon = "💪"

Streamlit code:

import streamlit as st
from st_pages import add_page_title, get_nav_from_toml

st.set_page_config(layout="wide")

# If you want to use the no-sections version, this
# defaults to looking in .streamlit/pages.toml, so you can
# just call `get_nav_from_toml()`
nav = get_nav_from_toml(".streamlit/pages_sections.toml")

st.logo("logo.png")

pg = st.navigation(nav)

add_page_title(pg)

pg.run()

Hiding pages

You can now pass a list of page names to hide_pages to hide pages from now on.

This list of pages is custom to each viewer of the app, so you can hide pages from one viewer but not from another using this method. You can see another example of hiding pages in the docs here

from st_pages import hide_pages

hide_pages(["Another page"])

Metadata

Release files for st-pages 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for st-pages 1.0.1
File Size Uploaded
st_pages-1.0.1.tar.gz 21.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for st-pages 1.0.1
File Interpreter ABI Platform
st_pages-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.4 kB

Release files / st_pages-1.0.1.tar.gz

Download URL st_pages-1.0.1.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2641cfbff1c768ff146858ed742d282b30a3a4c3e4f7717898705bbaee717736
BLAKE2b-256 checksum
How to use checksums
8360f9516698fc3952bba1d1b6c1cb0795aa82dac12473f5fb678066532268e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure

Release files / st_pages-1.0.1-py3-none-any.whl

Download URL st_pages-1.0.1-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9098fb4d96bc1dfa56cc2c56ef6fe44e607c69261ff4bceee1f6e9c1e0c2acb4
BLAKE2b-256 checksum
How to use checksums
a70477c5f0cdc21deb6eadd77bdbf88157632178865e71adffed728fa9e5b48b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.5.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page