Importing local CSS file into Streamlit

Hi there, I’m on Streamlit 1.31.1 and Python3

I’m using this setup and trying to import a local CSS file into example.py

Can anyone let me know how I import a local CSS file? I’ve tried this and moved the CSS file around into every single folder, but it’s still “not found”

# st.markdown('<link rel="stylesheet" href="custom.css">', unsafe_allow_html=True)

Would appreciate any advice!

Hey @streamlitisawesome,

Thanks for sharing your question! It looks like that link actually goes to a Zoom meeting.

@mathcatsand has a good example of using a CSS file here (pasting below):

import streamlit as st

st.title('A Random App')
st.write('Look at the pretty waves')

with open('./files/wave.css') as f:
    css = f.read()

st.markdown(f'<style>{css}</style>', unsafe_allow_html=True)