-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
feature:st.codeRelated to the `st.code` elementRelated to the `st.code` elementtype:bugSomething isn't working as expectedSomething isn't working as expected
Description
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
As of 1.21.0, the configuration setting of theme.font is being applied to code blocks. This was not the behavior in 1.20.0 (and earlier), and is directly contradicted by the configuration documentation which pretty explicitly states that this setting is to set the
Font family for all text in the app, except code blocks.
Reproducible Code Example
import streamlit as st
if st.session_state.setdefault("_first_run", True):
# Ensure we're starting from a clean slate for this test
st.config.set_option("theme.font", None)
st.session_state._first_run = False
st.experimental_rerun()
st.write("Font setting (if any): ", st.config.get_option("theme.font"))
st.code('{"key": "value"}', language="json")
if st.button("Set font to sans serif"):
st.config.set_option("theme.font", "sans serif")
st.experimental_rerun()Steps To Reproduce
- Run sample and observe visual appearance of code block
- Click "Set font to sans serif" button to set the script font to "sans serif"
- Observe the different font being applied to the code block
Expected Behavior
theme.font setting is not applied to code blocks
Current Behavior
theme.font setting is applied to code blocks
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.21.0
- Python version: 3.9.16 and 3.11.0
- Operating System: Ubuntu 22.04.2
- Browser: Chrome 111.0.5563.146
- Virtual environment: venv
Additional Information
For awareness, there is another documented issue related to code blocks in 1.21.0. I suspect this issue may relate to that one, but I'm not 100% certain that that is the case.
Are you willing to submit a PR?
- Yes, I am willing to submit a PR!
Metadata
Metadata
Assignees
Labels
feature:st.codeRelated to the `st.code` elementRelated to the `st.code` elementtype:bugSomething isn't working as expectedSomething isn't working as expected