Show API reference for

Configure a page for st.navigation in a multipage app.

Call st.Page to initialize a StreamlitPage object, and pass it to st.navigation to declare a page in your app.

When a user navigates to a page, st.navigation returns the selected StreamlitPage object. Call .run() on the returned StreamlitPage object to execute the page. You can only run the page returned by st.navigation, and you can only run it once per app rerun.

A page can be defined by a Python file, Callable, or external URL.

Function signature[source]

st.Page(page, *, title=None, icon=None, url_path=None, default=False, visibility="visible")

Parameters

page (str, Path, or callable)

The source for the internal or external page. This can be one of the following values:

  • callable: Streamlit executes the callable when it runs the page. The callable can't accept arguments.
  • Path to a Python file: Streamlit executes the Python script when it runs the page. The path can be a string or pathlib.Path object. It can be absolute or relative to the entrypoint file.
  • URL: Streamlit opens the URL in a new tab when a user selects it in the navigation menu or a page link. In this case, the app doesn't rerun. The URL must contain an HTTP or HTTPS scheme, like "https://docs.streamlit.io". If the page is defined by a URL, then the title parameter is required.

title (str or None)

The title of the page. If this is None (default), the page title (in the browser tab) and label (in the navigation menu) will be inferred from the filename or callable name in page. For more information, see Overview of multipage apps.

The title supports GitHub-flavored Markdown of the following types: Bold, Italics, Strikethrough, Inline Code, and Images. Images display like icons, with a max height equal to the font height.

Unsupported Markdown elements are unwrapped so only their children (text contents) render. Common block-level Markdown (headings, lists, blockquotes) is automatically escaped and displays as literal text in labels.

See the body parameter of st.markdown for additional, supported Markdown directives.

icon (str or None)

An optional emoji or icon to display next to the page title and label. If icon is None (default), no icon is displayed next to the page label in the navigation menu, and a Streamlit icon is displayed next to the title (in the browser tab). If icon is a string, the following options are valid:

  • A single-character emoji. For example, you can set icon="🚨"

    or icon="🔥". Emoji short codes are not supported.

  • An icon from the Material Symbols library (rounded style) in the

    format ":material/icon_name:" where "icon_name" is the name of the icon in snake case.

    For example, icon=":material/thumb_up:" will display the Thumb Up icon. Find additional icons in the Material Symbols font library.

  • "spinner": Displays a spinner as an icon. In this case, the spinner only displays next to the page label in the navigation menu. The spinner isn't used as the page favicon next to the title in the browser tab. The favicon is the default Streamlit icon unless otherwise specified with the page_icon parameter of st.set_page_config.

url_path (str or None)

The page's URL pathname, which is the path relative to the app's root URL. If this is None (default), the URL pathname will be inferred from the filename or callable name in page. For more information, see Overview of multipage apps.

The default page will have a pathname of "", indicating the root URL of the app. If you set default=True, url_path is ignored. url_path can't include forward slashes; paths can't include subdirectories.

default (bool)

Whether this page is the default page to be shown when the app is loaded. If default is False (default), the page will have a nonempty URL pathname. However, if no default page is passed to st.navigation and this is the first page, this page will become the default page. If default is True, then the page will have an empty pathname and url_path will be ignored.

visibility ("visible" or "hidden")

Whether the page is shown in the navigation menu. If this is "visible" (default), the page appears in the navigation menu. If this is "hidden", the page is excluded from the navigation menu. Hidden pages defined by Python files or callables remain accessible by st.page_link and st.switch_page. External URLs can always be accessed using st.page_link regardless of their inclusion or visibility in the navigation menu.

Note

Navigating to an internal page by URL starts a new session. For any internal page to be accessible by URL, it must be passed to st.navigation during the new session's initial script run. The page can be visible or hidden.

Returns

(StreamlitPage)

The page object associated to the given script.

Example

import streamlit as st

def page2():
    st.title("Second page")

pg = st.navigation([
    st.Page("page1.py", title="First page", icon="🔥"),
    st.Page(page2, title="Second page", icon=":material/favorite:"),
    st.Page(
        "https://docs.streamlit.io",
        title="Streamlit Docs",
        icon=":material/open_in_new:"
    ),
])
pg.run()

A page within a multipage Streamlit app.

Use st.Page to initialize a StreamlitPage object.

Class description[source]

StreamlitPage(page, *, title=None, icon=None, url_path=None, default=False, visibility="visible")

Methods

run()

Execute the page.

Attributes

icon (str)

The icon of the page.

If no icon was declared in st.Page, this property returns "".

title (str)

The title of the page.

Unless declared otherwise in st.Page, the page title is inferred from the filename or callable name. For more information, see Overview of multipage apps.

The title supports GitHub-flavored Markdown as described in st.Page.

url_path (str)

The page's URL pathname, which is the path relative to the app's root URL.

Unless declared otherwise in st.Page, the URL pathname is inferred from the filename or callable name. For more information, see Overview of multipage apps.

The default page will always have a url_path of "" to indicate the root URL (e.g. homepage).

visibility (Literal["visible", "hidden"])

Whether the page is shown in the navigation menu. If this is "visible" (default), the page appears in the navigation menu. If this is "hidden", the page is excluded from the navigation menu.

For internal pages, hidden pages remain accessible via direct URL, st.page_link, or st.switch_page. For external URL pages, hidden pages are not URL-accessible or switchable via st.switch_page; they can still be linked with st.page_link.

Note

Navigating to an internal page by URL starts a new session. For a hidden page to be accessible by URL, it must be passed to st.navigation during the new session's initial script run.

The external URL of the page, if this is an external link.

Whether this page is an external URL.

Execute the page.

When a page is returned by st.navigation, use the .run() method within your entrypoint file to render the page. You can only call this method on the page returned by st.navigation. You can only call this method once per run of your entrypoint file.

For external URL pages, this method does nothing as the navigation to the external URL is handled by the frontend.

Function signature[source]

StreamlitPage.run()

forum

Still have questions?

Our forums are full of helpful information and Streamlit experts.