-
Notifications
You must be signed in to change notification settings - Fork 4k
[feat][TextAlignment] add text alignment for heading elements. #13034
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!
|
12a03ee to
592b7d3
Compare
fa062dd to
0fdcfd7
Compare
592b7d3 to
f0d2c9d
Compare
0fdcfd7 to
776e3f8
Compare
776e3f8 to
9e99e17
Compare
f0d2c9d to
7d7919f
Compare
7d7919f to
098964f
Compare
9e99e17 to
a57ef80
Compare
a57ef80 to
da25075
Compare
098964f to
2e3c2d1
Compare
da25075 to
a7ddb15
Compare
9386492 to
e771f02
Compare
📉 Python coverage change detectedThe Python unit test coverage has decreased by 0.0000%
✅ Coverage change is within normal range. Coverage by files
|
3362430 to
dc7aee5
Compare
a639656 to
44c168a
Compare
dc7aee5 to
f232ac6
Compare
ec785ef to
2ac3d2c
Compare
c473e7b to
7d4d341
Compare
2ac3d2c to
cdb18b9
Compare
7d4d341 to
78b1b45
Compare
1d5abcb to
cdf6a3d
Compare
cdf6a3d to
274d56c
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.title, st.header, and st.subheader heading elements to allow developers to control horizontal text alignment. The implementation includes:
- New
text_alignmentparameter accepting "left", "center", "right", or "justify" - Default value of "left" for backward compatibility
- Comprehensive Python unit tests and E2E tests with visual snapshots
Key Changes
- Added
text_alignmentparameter to all three heading functions with consistent API design - Integrated parameter into
LayoutConfigfor backend processing - Added comprehensive unit tests covering valid values, defaults, and invalid inputs
- Added E2E tests with visual snapshot verification for different alignment options
Reviewed Changes
Copilot reviewed 4 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/streamlit/elements/heading.py |
Added text_alignment parameter to title, header, and subheader functions with validation and documentation |
lib/tests/streamlit/elements/heading_test.py |
Added parameterized unit tests for all three heading functions covering valid/invalid alignment values |
e2e_playwright/st_heading.py |
Added test cases demonstrating text alignment with help tooltips and dividers |
e2e_playwright/st_heading_test.py |
Added E2E tests with CSS verification and snapshot comparisons |
e2e_playwright/__snapshots__/linux/st_heading_test/*.png |
Added visual regression snapshots for different browsers |
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.
The right padding of the help icon seems to be a bit too much
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.
That's true, I need to work on the help icon more in the last PR that adds support for st.markdown so I think I will merge this for now but try to address this padding issue in the downstream PR.
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.
Oh, I realized this is because of the anchor button. I am making a note of this, but I guess it is completely separate from st.markdown.
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 👍

Describe your changes
Adds a new
text_alignmentparameter tost.title,st.headerandst.subheader.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.