date created: Tuesday, May 13th 2025, 8:35:23 am
date modified: Tuesday, May 13th 2025, 9:43:49 pm
tags:
- streamlit
- python
- css
title: How to load custom font in Streamlit
permalink: how-to-load-font-streamlit
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"