Hi @zxdawn,
- If you use the css hack, it will apply to all the elements of the same type, that exist on the page.
- I modified the code slightly, but this won’t work if you use emojis. If you are still interested, the code is below, along with a snapshot:
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