feat(logo): add support for Material icons and emojis in st.logo#13416
feat(logo): add support for Material icons and emojis in st.logo#13416lukasmasuch merged 15 commits intostreamlit:developfrom
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. |
|
Thanks for contributing to Streamlit! 🎈 Please make sure you have read our Contributing Guide. You can find additional information about Streamlit development in the wiki. The review process:
We're receiving many contributions and have limited review bandwidth — please expect some delay. We appreciate your patience! 🙏 |
|
@cursor review |
There was a problem hiding this comment.
Pull request overview
This PR adds support for Material icons and emojis in st.logo(), allowing users to pass icon strings (:material/home:) or emoji characters (🏠) instead of only image files. The implementation reuses the existing DynamicIcon component pattern from st.chat_message avatars.
Key Changes:
- Added
ImageTypeenum (IMAGE/EMOJI/ICON) to Logo protobuf with backward-compatible field numbering - Created
_process_logo_image()helper function to detect and validate input type (image/emoji/icon) - Modified frontend
LogoComponentto renderDynamicIconfor icons/emojis instead of<img>tags
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
proto/streamlit/proto/Logo.proto |
Added ImageType enum and two new fields (image_type, icon_image_type) to support icon/emoji detection |
lib/streamlit/commands/logo.py |
Added _process_logo_image() helper and updated logo() to handle emoji/icon strings, with updated docstrings |
lib/tests/streamlit/commands/logo_test.py |
Added 5 Python tests covering material icons, emojis, icons with links, mixed icon types, and invalid icons |
frontend/app/src/components/Logo/LogoComponent.tsx |
Added conditional rendering logic to use DynamicIcon when imageType is ICON or EMOJI |
frontend/app/src/components/Logo/LogoComponent.test.tsx |
Added 4 frontend tests verifying DynamicIcon rendering for ICON/EMOJI types |
frontend/app/src/components/Sidebar/styled-components.ts |
Added StyledIconLogo styled component for sizing icon/emoji logos |
Add support for using Material icons (e.g., `:material/home:`) and emojis (e.g., `🏠`) as logos in `st.logo()`, in addition to image files. Changes: - Add ImageType enum to Logo protobuf (IMAGE, EMOJI, ICON) - Add _process_logo_image() helper to detect and process icon/emoji/image - Integrate DynamicIcon component in frontend LogoComponent - Add StyledIconLogo styled component for icon/emoji rendering - Update docstrings to document new supported formats Closes streamlit#13385
- Map logo size (small/medium/large) to DynamicIcon size (lg/xl/twoXL) - Fix type annotation for image parameter to accept str for emoji/icons
0cc4f94 to
db0e0d5
Compare
|
Can you please add some screenshots of what this looks like with different emojis and icons, and different values for the |
SummaryThis PR adds support for Material icons and emojis in Key changes:
Code QualityCritical Issue: TypeScript Import ErrorFile: import { IconSize } from "@streamlit/lib"This import will fail at compile-time because export type { EmotionTheme, PresetThemeName, ThemeConfig } from "./theme"Fix: Change the import to use the internal path alias available in the app package: import { IconSize } from "~lib/theme"This is consistent with how other files in the codebase import Code Structure (Good)
Minor Observations
Test CoveragePython Unit Tests ✅The Python tests in
All tests include docstrings following the best practices. The tests verify both the Frontend Unit Tests ✅The frontend tests in
The tests follow RTL best practices, using E2E TestsNo new E2E tests were added. The PR description mentions this is intentional since the feature "relies on existing
However, consider adding at least one E2E test case with icon/emoji logos to verify the full integration. Backwards CompatibilityAssessment: Fully backwards compatible ✅
Security & RiskNo security concerns identified. ✅
Regression risk: Low
Recommendations
VerdictCHANGES REQUESTED: The PR has a critical TypeScript import error that will cause a build failure. The import of This is an automated AI review. Please verify the feedback and use your judgment. |
|
Hey @jrieke @lukasmasuch, apologies for going quiet on this one - life got in the way for a bit! I've made all the updates:
Let me know if there's anything else - always happy to help! |
|
@jrieke please can you remove |
|
Sorry for the delay. Reviewed the screenshots and they look good, approved from product side! Will send this to our eng team to review. |
SummaryAdds emoji and Material icon support to Code Quality
Test CoveragePython unit tests cover icon/emoji cases and invalid inputs; frontend unit tests cover icon/emoji rendering and collapsed behavior; e2e snapshots cover icon and emoji logos. The new e2e tests for icon/emoji do not include a “must NOT happen” assertion as recommended in Backwards CompatibilityProto changes are additive and should be wire-compatible. Note that emoji/icon logos will render as broken images on older frontends that don’t understand Security & RiskNo direct security concerns. Accepting arbitrary strings as logo images can still produce invalid media content (broken images) if the string is not a valid file/URL/emoji/icon. Recommendations
VerdictCHANGES_REQUESTED: Fix the invalid-string handling and the logo link accessibility before merge. This is an automated AI review using |
lukasmasuch
left a comment
There was a problem hiding this comment.
LGTM 👍 Thanks for the contribution.
|
Awesome, thanks for the contribution! @rahuld109 would love to send you some swag as a little thank you, feel free to fill out this form: https://docs.google.com/forms/d/e/1FAIpQLSe7cXh3H1DmrgNpVew9qViGIHX7vdEbTv5isA44_z5bgaKTKg/viewform |
Describe your changes
Adds support for Material icons and emojis in
st.logo():Following @lukasmasuch's suggestion, this passes the icon name to the frontend and reuses the existing
DynamicIconcomponent (same patternst.chat_messageuses for avatars).Changes:
ImageTypeenum in Logo protobuf (IMAGE/EMOJI/ICON)_process_logo_image()helper to detect input typeLogoComponentrendersDynamicIconfor icons/emojisStyledIconLogostyled component for sizingScreenshots
Material Icons - Size Parameter (small / medium / large)
Different Material Icons
Emoji Support
!emoji
GitHub Issue Link (if applicable)
Closes #13385
Testing Plan
DynamicIconE2E coverageContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.