Streamlit - Load custom font

Create a CSS file to load the custom font.

static/css/style.css

@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;700&display=swap");

Load the CSS in the Streamlit app.

ui.py

CSS_PATH = Path(__file__).parent / "static/css" / "style.css"


def load_css():
    with open(CSS_PATH) as f:
        st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)


load_css()

Configure the app to use the custom font.

.streamlit/config.toml

[theme]
font = "Geist"
Streamlit - Load custom font
Interactive graph