Hi, is it possible to change the fontsize and/or color in st.slider()
?
Like below, I want to enlarge the “Pick one case:” caption
Hi, is it possible to change the fontsize and/or color in st.slider()
?
Like below, I want to enlarge the “Pick one case:” caption
Hi @zxdawn, see if you can use the logic from here…
Cheers
Thanks. Unfortunately, It doesn’t work:
import streamlit as st
import streamlit.components.v1 as components
def ChangeWidgetFontSize(wgt_txt, wch_font_size = '12px'):
htmlstr = """<script>var elements = window.parent.document.querySelectorAll('*'), i;
for (i = 0; i < elements.length; ++i) { if (elements[i].innerText == |wgt_txt|)
{ elements[i].style.fontSize='""" + wch_font_size + """';} } </script> """
htmlstr = htmlstr.replace('|wgt_txt|', "'" + wgt_txt + "'")
components.html(f"{htmlstr}", height=0, width=0)
listTabs = [':satellite: Quickview', ':book: About']
tabs = st.tabs(listTabs)
ChangeWidgetFontSize(listTabs[0])
Oh, the css hack works!
st.markdown(
"""<style>
div[class*="stSlider"] > label > div[data-testid="stMarkdownContainer"] > p {
font-size: 20px;
}
</style>
""", unsafe_allow_html=True)
``
Hi @zxdawn,
import streamlit as st
import streamlit.components.v1 as components
def ChangeWidgetFontSize(wgt_txt, wch_font_size = '12px'):
htmlstr = """<script>var elements = window.parent.document.querySelectorAll('p'), i;
for (i = 0; i < elements.length; ++i)
{ if (elements[i].textContent.includes(|wgt_txt|))
{ elements[i].style.fontSize ='""" + wch_font_size + """'; } }</script> """
htmlstr = htmlstr.replace('|wgt_txt|', "'" + wgt_txt + "'")
components.html(f"{htmlstr}", height=0, width=0)
listTabs = ['Quickview', 'About']
tabs = st.tabs(listTabs)
ChangeWidgetFontSize(listTabs[0], '24px')
ChangeWidgetFontSize(listTabs[1], '9px')
The result looks like:
Cheers
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
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.
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.
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.
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.