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