I have an app with a series of buttons and checkboxes in a sidebar.
There seems to a large space before the title in the sidebar (as shown in screenshot).
I would like to know how I can reduce this space.
I have unsuccessfully tired the proposed solutions in the following links:
Any form of help would be appreciated.
Screenshot of app:
The code is shown here:
# import modules
import streamlit as st
# configure sidebar text and widgets
file = st.sidebar.file_uploader("Choose a file", key='a')
cb1 = st.sidebar.checkbox('1', key='b')
cb2 = st.sidebar.checkbox('2', key='c')
cb3 = st.sidebar.checkbox('3', key='d')
cb4 = st.sidebar.checkbox('4', key='e')
cb5 = st.sidebar.checkbox('5', key='f')
cb7 = st.sidebar.checkbox('6', key='g')
cb8 = st.sidebar.checkbox('7', key='h')
cb9 = st.sidebar.checkbox('8', key='i')
cb10 = st.sidebar.checkbox('9', key='j')
start_btn = st.sidebar.button('Run', key='k')
You can make use of this unofficial CSS hack by adding the following to your Streamlit app:
You can have a look at the code and demo here:
@dataprofessor Thank you for the help.
I tried your solution, but the space still has not been reduced.
I tried with a local host and also deployed it.
Here is a link: https://yeetswa-sidebar-test-ngrfhi.streamlitapp.com/
I tried using python 3.9 and 3.10, but still the same result.
Any ideas as to why I could not correctly implement your solution?
I went to your provided link and in Google Chrome, I clicked on View → Developer → Inspect Elements
and the following is what I see:
And it seems that the CSS element name for the ``stMarkdownContainer
was different for the app that you and I deployed (however the last segment seems to be the same
Therefore, could you try adding the following instead:
Please let me know if this works
Yes, that seems to have worked. However, the CSS element name for the stMarkdownContainer was different for me to the one you specified in your code. Appreciate the help.
Here is the code: