st.Page
Configure a page for st.navigation in a multipage app.
Call st.Page to initialize a Page 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 Page object. Call .run() on the returned Page 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.
| Class description[source] | |
|---|---|
st.Page(page, *, title=None, icon=None, url_path=None, default=False, visibility="visible", help=None) | |
| Methods | |
run() | Execute the page. |
| Attributes | |
page (str, Path, or callable) | The source for the internal or external page. This can be one of the following values:
|
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) and the page is defined by a file, Streamlit uses a leading emoji in the filename, if present. Otherwise, no icon is displayed next to the page label in the navigation menu, and the default Streamlit icon is displayed next to the title (in the browser tab). Pass icon="" to show no icon next to the page label and keep the default browser-tab icon, even when the filename contains an emoji. If icon is a non-empty string, the following options are valid:
|
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. Each page's URL pathname must be unique among all pages passed to st.navigation, including pages in different sections, hidden pages, and external URL pages. The default page will have a pathname of "", indicating the root URL of the app. If you set default=True, the page is served at the root URL instead of url_path, but its url_path or inferred pathname must still be unique. url_path can't include forward slashes because Streamlit doesn't support nested URL pathnames yet. To upvote support for nested pathnames, see GitHub issue #8971. |
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, Streamlit serves the page at the app's root URL, so its public pathname is "". The url_path you pass, or the inferred pathname if you omit it, must still be unique. |
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. |
help (str or None) | A short summary of the page, shown as a tooltip on the page's item in the navigation menu. If this is None (default), no tooltip is displayed. Write it to help users and agents find the right page without opening it. In one to three short sentences (about 200 characters), say what the page shows, what users can do there, and what sets it apart from similar pages. Describe the page itself, not its current values or step-by-step instructions. Streamlit shows the summary as soon as the page is passed to st.navigation, before the page runs. It's also the default tooltip of st.page_link for this page. The agent API (see server.enableAgentApi) reports it as the page's help in its snapshot, except for external-URL pages, which the snapshot doesn't list. It isn't shown on the page and doesn't set the meta description. The summary can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the body parameter of st.markdown. |
help (str) | The help text of the page, as Markdown. If no help was declared in st.Page, this property returns "". |
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. | |
Example
import streamlit as st def page2(): st.title("Second page") pg = st.navigation([ st.Page( "page1.py", title="First page", icon="๐ฅ", help=( "Quarterly sales by region and product line. " "Filter by region and download the table as CSV." ), ), 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()
StreamlitPage
Configure a page for st.navigation in a multipage app.
Call st.Page to initialize a Page 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 Page object. Call .run() on the returned Page 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.
| Class description[source] | |
|---|---|
StreamlitPage(page, *, title=None, icon=None, url_path=None, default=False, visibility="visible", help=None) | |
| Methods | |
run() | Execute the page. |
| Attributes | |
page (str, Path, or callable) | The source for the internal or external page. This can be one of the following values:
|
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) and the page is defined by a file, Streamlit uses a leading emoji in the filename, if present. Otherwise, no icon is displayed next to the page label in the navigation menu, and the default Streamlit icon is displayed next to the title (in the browser tab). Pass icon="" to show no icon next to the page label and keep the default browser-tab icon, even when the filename contains an emoji. If icon is a non-empty string, the following options are valid:
|
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. Each page's URL pathname must be unique among all pages passed to st.navigation, including pages in different sections, hidden pages, and external URL pages. The default page will have a pathname of "", indicating the root URL of the app. If you set default=True, the page is served at the root URL instead of url_path, but its url_path or inferred pathname must still be unique. url_path can't include forward slashes because Streamlit doesn't support nested URL pathnames yet. To upvote support for nested pathnames, see GitHub issue #8971. |
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, Streamlit serves the page at the app's root URL, so its public pathname is "". The url_path you pass, or the inferred pathname if you omit it, must still be unique. |
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. |
help (str or None) | A short summary of the page, shown as a tooltip on the page's item in the navigation menu. If this is None (default), no tooltip is displayed. Write it to help users and agents find the right page without opening it. In one to three short sentences (about 200 characters), say what the page shows, what users can do there, and what sets it apart from similar pages. Describe the page itself, not its current values or step-by-step instructions. Streamlit shows the summary as soon as the page is passed to st.navigation, before the page runs. It's also the default tooltip of st.page_link for this page. The agent API (see server.enableAgentApi) reports it as the page's help in its snapshot, except for external-URL pages, which the snapshot doesn't list. It isn't shown on the page and doesn't set the meta description. The summary can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the body parameter of st.markdown. |
help (str) | The help text of the page, as Markdown. If no help was declared in st.Page, this property returns "". |
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. | |
Example
import streamlit as st def page2(): st.title("Second page") pg = st.navigation([ st.Page( "page1.py", title="First page", icon="๐ฅ", help=( "Quarterly sales by region and product line. " "Filter by region and download the table as CSV." ), ), 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()
StreamlitPage.run
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() |
Tip
Want a new st.Page feature or found a bug? Browse open issues and react with a ๐ on the initial post of the ones that matter to you. Your votes help us prioritize what to work on next.
Still have questions?
Our forums are full of helpful information and Streamlit experts.