Hi i am new to streamlit. I am creating a list of buttons, but I see gaps between buttons due to some CSS issue. How can i create a list of buttons with minimal gap so that one button end and other’s start are at same without minimal gaps. See in expected pic, how Topics and More vertically side by side.
# 1. Import at the top of the file
from streamlit_option_menu import option_menu
# 2. Get unique PDF names from citation_data
citation_data = st.session_state.get('uss_poc_citation_data', [])
unique_pdfs = []
seen = set()
for citation in citation_data:
pdf = citation.get('filename', 'Unknown')
if pdf not in seen:
unique_pdfs.append(pdf)
seen.add(pdf)
st.session_state.uss_poc_search_pdf_list = unique_pdfs
# 3. Show vertical list of PDF options using option_menu
if unique_pdfs:
# Create a menu (no header, no icons)
with st.container():
selected_pdf = option_menu(
menu_title="", # No header
options=unique_pdfs,
icons=[""] * len(unique_pdfs), # No icons
default_index=unique_pdfs.index(st.session_state.get('uss_poc_selected_pdf', unique_pdfs[0]))
if unique_pdfs and st.session_state.get('uss_poc_selected_pdf') in unique_pdfs else 0,
orientation="vertical"
)
# Handle selection like a button click
if selected_pdf != st.session_state.get('uss_poc_selected_pdf'):
st.session_state.uss_poc_pdf_selection_method = 'citation'
st.session_state.uss_poc_from_query_citation = False
st.session_state.uss_poc_selected_pdf = selected_pdf
if 'uss_poc_pdf_citation_indices' not in st.session_state:
st.session_state.uss_poc_pdf_citation_indices = {}
st.session_state.uss_poc_pdf_citation_indices[selected_pdf] = 0
Can we customise this?
I want to remove the triangular icon on each row, change background color and selection box color from blue to red. I tried custom CSS but it is not working for some reason.
Are you able to share a sample of how you’re creating the buttons originally? What you’ve shown in your screenshot seems to have the buttons spaced much further apart than if you’d just done something like
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.