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.
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.