-
Notifications
You must be signed in to change notification settings - Fork 4k
Add icon support to dialogs #13244
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
Add icon support to dialogs #13244
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. |
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 adds comprehensive icon support to Streamlit dialogs across the full stack. Users can now optionally display an emoji, Material Symbol, or spinner icon next to dialog titles using the new icon parameter in both st.dialog decorator and the internal _dialog method.
Key changes:
- Added protobuf field for dialog icons with backward compatibility
- Backend validates and forwards icons through the dialog creation pipeline
- Frontend renders icons with proper styling using the existing
DynamicIconcomponent
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| proto/streamlit/proto/Block.proto | Added optional icon field (field number 6) to Dialog message for protobuf compatibility |
| lib/streamlit/elements/lib/dialog.py | Added icon parameter to _create method with validation via validate_icon_or_emoji |
| lib/streamlit/elements/layouts.py | Updated _dialog method signature to accept and forward icon parameter |
| lib/streamlit/elements/dialog_decorator.py | Extended @st.dialog decorator with icon parameter and documentation |
| lib/tests/streamlit/elements/layouts_test.py | Added tests for icon propagation in both direct usage and decorator patterns |
| frontend/lib/src/components/elements/Dialog/styled-components.ts | Added flex layout styles for icon container with proper alignment |
| frontend/lib/src/components/elements/Dialog/Dialog.tsx | Integrated DynamicIcon component with conditional rendering based on icon presence |
| frontend/lib/src/components/elements/Dialog/Dialog.test.tsx | Added tests verifying icon rendering when present and absent |
|
@cursor review |
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.
✅ Bugbot reviewed your changes and found no bugs!
|
@KaranPradhan266 thanks for submitting this PR! I am wondering if you could look into whether there are some e2e tests that could be added for this? Since it is a visual change, I think it would be a good idea. |
|
@sfc-gh-lwilby Sure, will look into it! |
|
Also linking @jrieke for doing a quick product review |
SummaryThis PR adds optional icon support to Key Changes:
Code QualityThe implementation is clean, well-organized, and follows existing Streamlit patterns: ✅ Good Patterns Followed:
✅ Proto Change (Block.proto:128):
✅ Frontend Code (Dialog.tsx:162-166):
✅ Styled Components (styled-components.ts:19-32):
Test CoveragePython Unit Tests (layouts_test.py:1037-1060):
Frontend Unit Tests (Dialog.test.tsx:84-106):
E2E Tests (st_dialog_test.py:291-297):
Minor Suggestions for Test Coverage:
Backwards Compatibility✅ Fully Backwards Compatible:
Security & Risk✅ No Security Concerns:
✅ Low Regression Risk:
Recommendations
VerdictAPPROVED: This is a well-implemented feature that follows Streamlit patterns, includes appropriate test coverage across all layers (Python, TypeScript, E2E), maintains backwards compatibility, and poses no security risks. The suggestions above are optional enhancements rather than required changes. This is an automated AI review. Please verify the feedback and use your judgment. |
|
@lukasmasuch @sfc-gh-lwilby In my next commit, I’ll be covering updates to the icon comment descriptions, adding snapshot tests to verify both material-style and emoji icons, and adding a test to assert that the spinner icon’s test ID is visible. In addition to these updates, let me know if there is anything else you’d like me to address? |
|
@sfc-gh-lmasuch @sfc-gh-lwilby @jrieke Let me know if these look good! |
5970f6e to
2c4ce27
Compare
|
LGTM from product/design side! |
|
@KaranPradhan266 it looks like you will need to commit your snapshots that you added now. You can run |
| click_button(app, "Open Dialog without Images") | ||
|
|
||
|
|
||
| def open_dialog_with_icon(app: Page): |
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.
[nit] We would more typically just combine the tests to take the snapshot and the tests to check the icon, then I think we don't need this helper functions. But this isn't blocking since it is a more minor style decision with how to write tests. Your tests are more focused on testing one thing.
sfc-gh-lwilby
left a comment
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.
Thanks @KaranPradhan266, just a minor comment on the e2e tests, but it is not blocking.
sfc-gh-lwilby
left a comment
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.
Sorry, @KaranPradhan266 I just noticed there is an e2e test failing that might be related -- maybe affected by the tests you added because if I remember correctly, the CI was passing previously? Lukas just merged a fix for dialogs, so maybe rebasing on develop and fixing the merge conflict as well will help with the test failure.
|
@sfc-gh-lwilby @lukasmasuch I looked into the failing tests and none of the failures appear to be caused by changes in this PR. The Python unit test failure seems related to LoginHandlerTest, unlikely because of curent changes. For Playwright e2e, the failure is isolated to test_dialog_with_chart and occurs only on Firefox. This looks like test flakiness due to using a fixed hover position ({x: 80, y: 200}), not the dialog icon changes.
We can make the test more deterministic by hovering using the chart’s bounding box instead. I can push a fix for the test if you’d like, but it would be unrelated to this PR. Let me know how you’d like to proceed.
|
|
Thanks for looking into these failures @KaranPradhan266 . Apologies for the flaky test, unfortunately, it seems like maybe adding more elements into the test file for your tests is triggering the failure in this other test even though that test already had this flaw. If you have time to fix this other test it will help merge your PR faster. We can't merge it with the test failing because it will break develop. For the python unit test, I agree it doesn't apper related to your changes exactly, but it seems to also be persistently failing so it needs to be resolved before merging into the develop to keep develop green. I wonder if something went wrong when you merged in develop and fixed the merge conflict. I can try to take a look if you don't have time, but if you have time to resolve these fixes that will likely be the fastest solution because I have some other priorities to attend to first. Thanks again! Sorry these test failures are getting in the way of merging your PR. |
|
@KaranPradhan266 an update on the |
|
@sfc-gh-lwilby Thanks for the update! I’ve pushed the latest changes, which should now handle the e2e failures as well. Please let me know if you still see any issues on your end. |
|
@lukasmasuch My apologies for the oversight on type checker part, resolved it! |
|
@lukasmasuch @sfc-gh-lwilby I believe all feedback has been addressed, can you confirm whether this PR is ready to merge, or if there’s anything else needed? |
sfc-gh-lwilby
left a comment
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.
Thank you @KaranPradhan266 ! Thanks for fixing our flaky test as well :)
lukasmasuch
left a comment
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.
LGTM 👍 Removed one accidental method call (probably from a recent merge).



Describe your changes
_dialog/@st.dialog) validates and forwards it, and the frontend renders the icon next to the dialog title with refreshed styling.Screenshot or video (only for visual changes)
Screen.Recording.2025-12-06.at.1.11.48.PM.mov
GitHub Issue Link (if applicable)
Issue - #13202
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.