Is there a way to remove the side navigation bar containing file names in the latest version of streamlit?

Question:

I recently upgraded streamlit to version 1.10.0. After upgradation I ran streamlit only to find that there is a side navigation bar displaying python file names present in my directory. I have attached images for the same.

import streamlit as st
import pandas as pd
from services.multiapp import MultiApp
from functools import partial
from pages import show, analysis, help, custom, download, three_d


def refresh():
    pass


file = st.file_uploader('Upload CSV file',
                        type='csv', help="Format")
if file is not None:
    # verification
    # Prediction
    st.button("Refresh", on_click=refresh)
    data = pd.read_csv(file)
    app = MultiApp()
    app.add_app('Show data', partial(show.app, data))
    app.add_app('Analysis', analysis.app)
    app.add_app('Custom Plots', custom.app)
    app.add_app('3-D Plots', partial(three_d.app, data))
    app.add_app('Download', partial(download.app, data, file.name))
    app.add_app('Help', help.app)
    app.run()

enter image description here

Please help me to remove the side navigation bar.

My current working directory has the following structure

├── app.py
├── pages
│   ├── analysis.py
│   ├── custom.py
│   ├── download.py
│   ├── help.py
│   ├── __pycache__
│   │   ├── analysis.cpython-38.pyc
│   │   ├── analysis.cpython-39.pyc
│   │   ├── custom.cpython-38.pyc
│   │   ├── custom.cpython-39.pyc
│   │   ├── download.cpython-38.pyc
│   │   ├── download.cpython-39.pyc
│   │   ├── get_df.cpython-38.pyc
│   │   ├── help.cpython-38.pyc
│   │   ├── help.cpython-39.pyc
│   │   ├── iplots.cpython-38.pyc
│   │   ├── plot.cpython-38.pyc
│   │   ├── show.cpython-38.pyc
│   │   ├── show.cpython-39.pyc
│   │   ├── show_d.cpython-38.pyc
│   │   ├── three_d.cpython-38.pyc
│   │   └── three_d.cpython-39.pyc
│   ├── show.py
│   └── three_d.py
├── __pycache__
│   ├── multiapp.cpython-38.pyc
│   └── plots.cpython-38.pyc
├── README.md
├── services
│   ├── multiapp.py
│   ├── __pycache__
│   │   ├── multiapp.cpython-38.pyc
│   │   └── multiapp.cpython-39.pyc
│   └── services.py
├── Templates
│   ├── links.txt
│   ├── multi-page-app-main
│   │   ├── app.py
│   │   ├── apps
│   │   │   ├── data.py
│   │   │   ├── home.py
│   │   │   ├── model.py
│   │   │   └── __pycache__
│   │   │       ├── data.cpython-38.pyc
│   │   │       ├── home.cpython-38.pyc
│   │   │       └── model.cpython-38.pyc
│   │   ├── multiapp.py
│   │   ├── __pycache__
│   │   │   └── multiapp.cpython-38.pyc
│   │   ├── README.md
│   │   └── requirements.txt
│   ├── streamlit-dashboard-template-main
│   │   ├── app.py
│   │   ├── dashboard.py
│   │   ├── README.md
│   │   ├── stdashdark.png
│   │   └── stdashlight.png
│   ├── streamlit-geospatial-master
│   │   ├── app.py
│   │   ├── apps
│   │   │   ├── basemaps.py
│   │   │   ├── census.py
│   │   │   ├── cesium.py
│   │   │   ├── deck.py
│   │   │   ├── device_loc.py
│   │   │   ├── gee_datasets.py
│   │   │   ├── gee.py
│   │   │   ├── heatmap.py
│   │   │   ├── home.py
│   │   │   ├── housing.py
│   │   │   ├── plotly_maps.py
│   │   │   ├── raster.py
│   │   │   ├── rois.py
│   │   │   ├── timelapse.py
│   │   │   ├── vector.py
│   │   │   ├── wms.py
│   │   │   └── xy.py
│   │   ├── data
│   │   │   ├── cog_files.txt
│   │   │   ├── html
│   │   │   │   └── sfo_buildings.html
│   │   │   ├── realtor_data_dict.csv
│   │   │   ├── us_counties.geojson
│   │   │   ├── us_metro_areas.geojson
│   │   │   ├── us_nation.geojson
│   │   │   └── us_states.geojson
│   │   ├── environment-bk.yml
│   │   ├── index.html
│   │   ├── LICENSE
│   │   ├── multiapp.py
│   │   ├── packages.txt
│   │   ├── Procfile
│   │   ├── README.md
│   │   ├── requirements.txt
│   │   └── setup.sh
│   ├── Streamlit-master
│   │   ├── app.py
│   │   ├── data
│   │   │   ├── demo.wav
│   │   │   ├── Salary_Data.csv
│   │   │   ├── sal.jpg
│   │   │   ├── snippets
│   │   │   └── virtual.mp4
│   │   ├── data.py
│   │   ├── demo.py
│   │   ├── layout.py
│   │   ├── plots.py
│   │   ├── Procfile
│   │   ├── README.md
│   │   ├── requirements.txt
│   │   ├── sidebar.py
│   │   └── widget.py
│   └── streamlit template
│       ├── JC-202103-citibike-tripdata.csv
│       ├── logo.png
│       ├── requirements.txt
│       └── streamlit_template.py
├── test.csv
└── test.py
Asked By: Mystic Mickey

||

Answers:

Streamlit sidebar picks everything up that is located in the "pages" folder (see here: Blog Streamlit)

You could either rename your pages folder to something else or if you like the side bar, you can just collapse it initially:

import streamlit as st
st.set_page_config(initial_sidebar_state="collapsed")

That way the sidebar will be closed on start but can still be opened if needed.

Answered By: G43beli

Add this to all the pages you want to hide the page list from, but there should not be any ‘ul’ in your page except for the page list.

st.markdown("<style> ul {display: none;} </style>", unsafe_allow_html=True)
Answered By: Rahul S

A little late to this question, but I added the following snippet to the pages that I wanted to hide the lists on.

no_sidebar_style = """
    <style>
        div[data-testid="stSidebarNav"] {display: none;}
    </style>
"""
st.markdown(no_sidebar_style, unsafe_allow_html=True)

This got rid of the Streamlit generated page components on the sidebar and let me keep all my other components.

Answered By: sumshyftw
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.