Hello everybody!
I’m excited to introduce st-flexible-callout-elements
, a new library that allows you to create customizable callout messages directly within your Streamlit apps.
While Streamlit’s built-in callout messages (st.error, st.success, st.info, st.warning) are great to see the status of processes, I needed more control over styling to make my apps look just right. Like my previous release, I was working on this for myself and thought I could make it available for others.
Live Demo. Documentation. Pypi.
You can easily install it through pip:
pip install st-flexible-callout-elements
The main function of the library flexible_callout()
can handle several arguments for customization.
import streamlit as st
from st_flexible_callout_elements import flexible_callout
flexible_callout(message, container=st, background_color="#D9D9D9", font_color="#000000", font_size=16, alignment="left", line_height=1.5, border_radius=8, padding=15, margin_bottom=20)`
Calling the function with just a message and no other arguments, e.g.:
flexible_callout("This is the standard flexible callout.")
Will result in:
There are also four companion functions flexible_error()
, flexible_success()
, flexible_warning()
, and flexible_info()
that emulate streamlit’s: st.error()
, st.success()
, st.info()
, st.warning()
. They have most of the same arguments as flexible_callout()
with the exception of background_color
and font_color
which are fixed to match their counterparts.
import streamlit as st
from st_flexible_callout_elements import flexible_error, flexible_success, flexible_warning, flexible_info
flexible_error("This is a slightly larger error message.", font_size=20)
flexible_success("This is a centered success message", alignment="center")
flexible_warning("This is right aligned a warning message <b><u>with html elements</b></u>", alignment="right")
flexible_info("This is a slightly smaller info message", font_size=10)
As the post is getting long, I’ll leave you a few other images as examples (their code is properly documented on github and Pypi).
I hope you find st_flexible_callout_elements
useful for your Streamlit projects. Please let me know if you have any feedback or suggestions!
Cheers!