There’s an old question on this topic but the self-answer involved a broken link to Google’s natural language docs.
I figured out how to make bullet points with st.markdown() but I can’t figure out how to indent them.
st.write(“The following list won’t indent no matter what I try:”)
st.markdown(“- Item 1”)
st.markdown(“- Item 2”)
st.markdown(“- Item 3”)
Seems the main Docs entry doesn’t show anything except bold and italics. Elsewhere the Docs mention Github Flavored Markdown (GFM) but it’s confusing because those span multiple lines in a way not supported by st.markdown() and also when I try any of the symbols from GFM like > it doesn’t work.
import streamlit as st
st.write("The following list won’t indent no matter what I try:")
st.markdown("- Item 1")
st.markdown("- Item 2")
st.markdown("- Item 3")
st.markdown('''
<style>
[data-testid="stMarkdownContainer"] ul{
list-style-position: inside;
}
</style>
''', unsafe_allow_html=True)
or:
import streamlit as st
st.write("The following list won’t indent no matter what I try:")
st.markdown("- Item 1")
st.markdown("- Item 2")
st.markdown("- Item 3")
st.markdown('''
<style>
[data-testid="stMarkdownContainer"] ul{
padding-left:40px;
}
</style>
''', unsafe_allow_html=True)
Oh yes that’s very helpful. Thanks for showing me this syntax.
Update - perhaps I’m doing something wrong, but this latter method is actually not indenting for me. Does it need extra spaces to indicate that it should be indented?
Ah, it works if I use it in combination with the earlier CSS.
Hey all Apologies for the confusion. I didn’t realize I had @ji_haoran’s CSS hack pasted at the bottom of my code. @hack-r you’re right that the indentation works only in combination with the earlier CSS. This is likely a bug and you could submit an issue on GitHub about it.