-
Notifications
You must be signed in to change notification settings - Fork 4k
[Fix] Font fallback & sidebar page nav font #12948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
📈 Significant wheel size change detectedThe wheel file size has increased by 0.87% (threshold: 0.25%)
Please verify this change is expected. |
f74e2df to
ff42b51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the parseFont function to always append Streamlit's default font as a final fallback when custom fonts are used. This ensures that if custom fonts fail to load, Streamlit's default fonts are used instead of the browser's defaults.
Key Changes
- Modified
parseFontfunction to accept an optionalfallbackFontparameter and always append it to the font string - Updated all call sites of
parseFontto pass appropriate fallback fonts (sans-serif for body/heading, monospace for code) - Updated tests to reflect new behavior where all custom fonts have Streamlit's default fallback appended
- Added navigation component styling to use theme's bodyFont
Reviewed Changes
Copilot reviewed 3 out of 9 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| frontend/lib/src/theme/utils.ts | Modified parseFont to accept fallback parameter and always append it; updated all parseFont calls to pass appropriate fallbacks |
| frontend/lib/src/theme/utils.test.ts | Updated test expectations to match new behavior; added tests for custom fallback parameter |
| frontend/app/src/components/Navigation/styled-components.ts | Added fontFamily styling to sidebar navigation container |
| e2e_playwright/snapshots/linux/custom_url_base_test/custom_theme_with_url_base[webkit].png | Updated snapshot to reflect visual changes from font fallback behavior |
Describe your changes
This PR resolves 2 font related issues for custom themes:
Sidebar page navigation menu should use sidebar font


Current:
After:
Fallback to Streamlit default font instead of browser default when font file can’t be found


Current: result when
theme.fontset to invalid sourceAfter:
Testing Plan