Skip to content

Allow links to external web pages in the new navigation sidebar #9025

@mahotd

Description

@mahotd

Checklist

  • I have searched the existing issues for similar feature requests.
  • I added a descriptive title and summary to this issue.

Summary

I want to add a link to an external web page at the top of the sidebar navigation created by st.navigation. I tried using a st.page_link but it ends up below the navigation menu.

Why?

I need this to redirect my users to the homepage of the project (which isn't a Streamlit app)

How?

This can be solved in different ways :

  • allow the st.Page widget to target external pages
  • create a st.ExternalPage widget which can be fed into the st.navigation widget.
  • allow the user to add custom content inside the sidebar navigation created by st.navigation

Additional Context

Minimal working example :

# -*- coding: utf-8 -*-

import streamlit as st


def main():
    st.sidebar.page_link(
        page="https://mywebsite.com/home/",
        label="**Home**",
        icon="🏠",
    )

    def page1():
        st.write("This is page 1")

    def page2():
        st.write("This is page 2")

    pages = {
        "Section 1": [
            st.Page(page1, title="Page 1", icon="🔐"),
        ],
        "Section 2": [
            st.Page(page2, title="Page 2", icon="📚"),
        ],
    }

    pg = st.navigation(pages)
    pg.run()


if __name__ == "__main__":
    main()

Which looks like:

image

Ideally the 🏠 Home button would be above the navigation menu.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions