Search code examples
pythoncsspython-3.xmarkdownstreamlit

How to reduce line spacing in bulleted list in Streamlit?


How do I reduce the line spacing between bullet points in st.markdown?

Code

st.markdown('- Item 1')
st.markdown('- Item 2')
st.markdown('- Item 3')

Current Output (would like to reduce the space as indicated)

enter image description here


Solution

  • If you put the text inside the same markdown element, you can get something like this, which is a bit closer (items 4 & 5):

    markdown space

    import streamlit as st
    
    st.markdown("- Item 1")
    st.markdown("- Item 2")
    st.markdown("- Item 3")
    
    st.markdown("- Item 4  \n- Item 5  ")