-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[feat][TextAlignment] Adds text alignment parameter to st.text
#13032
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!
|
st.text
67bc96f to
ea72594
Compare
5276414 to
52b3e19
Compare
ea72594 to
a4fb6de
Compare
52b3e19 to
3534c40
Compare
a0eca20 to
1fac3bd
Compare
3534c40 to
cc1a727
Compare
1fac3bd to
3ea3a2d
Compare
cc1a727 to
82cdfb7
Compare
3ea3a2d to
319b016
Compare
📈 Python coverage change detectedThe Python unit test coverage has increased by 0.0495%
🎉 Great job on improving test coverage! Coverage by files
|
319b016 to
9ca8e02
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 adds a text_alignment parameter to st.text, allowing users to align text horizontally within the element using "left" (default), "center", "right", or "justify" options.
Key Changes
- Added
text_alignmentparameter to thest.textPython API with validation - Updated frontend styling to support inline help icons with text alignment
- Added comprehensive Python unit tests and E2E tests with snapshot testing
Reviewed Changes
Copilot reviewed 9 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/streamlit/elements/text.py | Added text_alignment parameter to st.text() method signature and documentation |
| lib/tests/streamlit/elements/text_test.py | Added parameterized tests for text alignment validation and protobuf value checking |
| frontend/lib/src/components/elements/TextElement/TextElement.tsx | Updated to nest help icon inside text span for proper alignment |
| frontend/lib/src/components/elements/TextElement/styled-components.ts | Changed from div to span for inline display and added inline help icon styling |
| frontend/lib/src/components/shared/TooltipIcon/styled-components.ts | Updated to ensure full width and proper centering for text alignment |
| frontend/lib/src/components/shared/TooltipIcon/index.ts | Reordered exports (cosmetic change) |
| e2e_playwright/st_text.py | Added test cases for all text alignment options with help tooltips |
| e2e_playwright/st_text_test.py | Added parameterized E2E test for visual validation of text alignment |
| e2e_playwright/shared/app_utils.py | Added get_text() utility function for locating text elements |
| e2e_playwright/snapshots/* | Added snapshot images for alignment validation across browsers |
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 👍
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.
is the space in front of demonstrate expected? This is probably caused by the tab/spaces in front of demonstrate

Describe your changes
Adds a new
text_alignmentparameter tost.text.GitHub Issue Link (if applicable)
#4109
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.