[Python] Is it possible to change the font of a st.button in Streamlit?

Discussão em 'Python' iniciado por Stack, Setembro 9, 2025.

  1. Stack

    Stack Membro Participativo

    I’m trying to change the font of a st.button in Streamlit, but so far nothing works.

    I tried using CSS injection with st.markdown:

    import streamlit as st

    st.markdown(
    """
    <style>
    div.stButton > button {
    font-family: "Courier New", sans-serif !important;
    font-size: 20px !important;
    }
    </style>
    """,
    unsafe_allow_html=True
    )

    if st.button("Click me", use_container_width=True):
    st.success("Clicked!")


    I also tried embedding fonts via base64.

    Refreshing or clearing cache doesn’t help.

    Forum threads suggest using @font-face or custom CSS for components inside iframes, but this is just a regular button.

    Is it currently possible to change the font of a st.button in Streamlit? If not, are there any workarounds to display a button-like component with a custom font?

    Continue reading...

Compartilhe esta Página