[feature] Add alignment parameter to column_config columns#14333
[feature] Add alignment parameter to column_config columns#14333lukasmasuch merged 8 commits intodevelopfrom
alignment parameter to column_config columns#14333Conversation
Add alignment parameter to st.column_config.Column and all typed column configs to control horizontal text alignment in dataframe cells. The frontend already supports this via Glide Grid's contentAlign property. - Add ContentAlignment type alias (Literal["left", "center", "right"]) - Add alignment parameter to all 19 column config functions - Add unit tests and E2E test for alignment - Add product spec for the feature Closes #12106 Co-Authored-By: Claude Opus 4.6 <[email protected]>
✅ PR preview is ready!
|
✅ 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.
Pull request overview
This PR exposes horizontal cell-content alignment in st.dataframe / st.data_editor by adding an alignment parameter to st.column_config.Column and all typed column config helpers, leveraging the frontend’s existing support for Glide Data Grid contentAlign.
Changes:
- Added
ContentAlignmenttype alias andalignmenttoColumnConfigplus all column config helper functions. - Added Python unit tests to ensure
alignmentis propagated into the produced column config dict. - Extended the Playwright dataframe configuration screenshot test app + assertions to cover alignment.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
specs/2026-03-11-dataframe-column-alignment/product-spec.md |
New product spec describing the alignment API and intended behavior. |
lib/streamlit/elements/lib/column_types.py |
Adds ContentAlignment + alignment to Column() and all typed column configs, and updates docstrings/types. |
lib/tests/streamlit/elements/lib/column_types_test.py |
Adds unit tests for alignment propagation and default omission behavior. |
e2e_playwright/st_dataframe_config.py |
Adds a new “Column alignment” example dataframe for visual verification. |
e2e_playwright/st_dataframe_config_test.py |
Increments expected dataframe count and adds a new snapshot assertion for the alignment example. |
Updated the alignment parameter docstring for NumberColumn to note that some number-like types (e.g., durations) may use a different default alignment. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
The snapshot autofix workflow could not update snapshots. This can happen if:
Please check the workflow run logs for details. If you need to update snapshots manually, you can:
You can re-run this workflow by removing and re-adding the |
## Describe your changes Automated snapshot updates for #14333 created via the snapshot autofix CI workflow. This workflow was triggered by adding the `update-snapshots` label to a PR after Playwright E2E tests failed with snapshot mismatches. **Updated snapshots:** 6 file(s)⚠️ **Please review the snapshot changes carefully** - they could mask visual bugs if accepted blindly. This PR targets a feature branch and can be merged without review approval. Co-authored-by: Streamlit Bot <[email protected]>
SummaryThis PR adds an Key changes:
Code QualityAll three reviewers agree: the code is clean, well-typed, and follows existing codebase patterns precisely. Specific points of consensus:
No code quality issues were identified by any reviewer. Test CoverageAll three reviewers agree: test coverage is thorough and adequate.
Backwards CompatibilityUnanimous agreement: fully backwards compatible.
Security & RiskUnanimous agreement: no security concerns. The change is purely additive to the Python API and maps to an already-supported frontend rendering property. No changes to routing, auth, WebSocket handling, embedding, assets, or cross-origin behavior. Regression risk is very low. External test recommendation
AccessibilityAll reviewers agree: no accessibility concerns. The alignment is purely visual (CSS Reviewer Agreement & Conflict ResolutionAll three reviewers ( Minor differences in optional recommendations are noted below — none are blocking. RecommendationsNo blocking issues. Optional follow-up suggestions from individual reviewers (non-blocking):
Missing ReviewsAll expected models completed their reviews:
VerdictAPPROVED: All three reviewers unanimously approve. The implementation is clean, additive, well-tested (unit + E2E + visual regression), fully backwards-compatible, and carries no security or regression risk. It correctly exposes an already-supported frontend capability through the Python API, following existing codebase patterns precisely. This is a consolidated AI review by 📋 Review by `gemini-3.1-pro`SummaryThis PR adds an Code QualityThe code changes are clean, well-typed, and follow the existing patterns in Test CoverageThe test coverage is excellent:
Backwards CompatibilityThe change is fully backwards compatible. The Security & RiskNo security concerns. The change only exposes an existing frontend property to the Python API and does not introduce any new dependencies, execution paths, or cross-origin behaviors. External test recommendation
AccessibilityThe alignment changes are visual and rely on the underlying Glide Data Grid implementation. No negative impact on accessibility is expected. RecommendationsNone. The PR is well-implemented, well-tested, and ready to merge. VerdictAPPROVED: The PR successfully exposes the column alignment feature with excellent code quality and test coverage. This is an automated AI review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR adds an Code QualityThe implementation is consistent and maintainable:
No code-quality issues were identified that should block merge. Test CoverageCoverage is good for this scope:
Overall, tests are adequate for this change. Backwards CompatibilityNo breaking changes found:
Security & RiskNo security-sensitive surfaces are modified. The PR does not touch auth/session logic, routes, websocket transport, asset serving, CSP/CORS, storage, or dynamic code execution paths. Regression risk is low and mostly limited to display alignment behavior in dataframes/data editors. External test recommendation
AccessibilityNo direct accessibility regressions were identified. The change affects horizontal content alignment only and does not alter semantics, keyboard interaction, focus management, or ARIA behavior. Snapshot tests provide visual confidence but do not replace dedicated accessibility assertions. Recommendations
VerdictAPPROVED: The implementation is clean, additive, well-tested for the feature scope, and ready for merge. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR adds an The change is purely an API-exposure task — the Key changes:
Code QualityThe code is clean, consistent, and follows existing patterns precisely. Specific observations:
No issues found. Test CoverageUnit Tests (
E2E Tests (
Coverage assessment: Tests adequately cover the happy path (all three alignment values on all column types), the default behavior (None exclusion), and visual appearance (E2E snapshots). One minor observation: there is no test for invalid alignment values (e.g., passing Backwards CompatibilityFully backwards compatible:
Security & RiskNo security concerns:
Regression risk is very low — the only code path affected is column config construction, and the External test recommendation
AccessibilityNo accessibility concerns. The
The alignment is applied via Glide Data Grid's built-in RecommendationsNo blocking issues. A few minor, non-blocking observations:
VerdictAPPROVED: Clean, well-tested, fully backwards-compatible feature that exposes an already-supported frontend capability through the Python API. The implementation is consistent with existing codebase patterns, has good test coverage (unit + E2E + visual regression), and carries no security or regression risk. This is an automated AI review by |
alignment parameter to column_config columns
Several column types (SelectboxColumn, chart columns, ProgressColumn, ListColumn, MultiselectColumn) use third-party or custom renderers that don't honor glide-data-grid's contentAlign property. This removes the alignment parameter from these columns to avoid misleading users. Also updates the E2E test to use right-aligned checkbox (instead of center) to actually demonstrate the alignment feature works, since checkboxes are center-aligned by default. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
SummaryThis PR adds an Column types that use custom renderers ( Reviewer AgreementAll three reviewers (gemini-3.1-pro, gpt-5.3-codex-high, opus-4.6-thinking) are in unanimous agreement on all major points:
No disagreements were found between any of the reviewers. Code QualityThe implementation is clean and consistent:
Test CoverageCoverage is thorough and appropriately layered:
Backwards CompatibilityFully backwards compatible. No breaking changes: all new parameters are keyword-only with Security & RiskNo security concerns. Changes are limited to UI rendering configuration (column alignment) with no impact on auth, networking, WebSocket handling, file serving, or code execution paths. External test recommendation
AccessibilityAccessibility-neutral. Cell alignment is a visual styling property in Glide Data Grid's canvas rendering. No ARIA attributes or semantic HTML are affected. Default alignment conventions (numbers right-aligned, text left-aligned) are preserved. Recommendations
VerdictAPPROVED: All three reviewers unanimously approved. The PR is a clean, well-tested, backwards-compatible feature addition that exposes an existing frontend capability through the Python API, accompanied by a correct operator precedence bug fix in This is a consolidated AI review by 📋 Review by `gemini-3.1-pro`SummaryThis PR introduces a new Code QualityThe code is well-structured and follows the established patterns for adding parameters to
Test Coverage
Backwards CompatibilityThe changes are fully backwards compatible. The Security & RiskNo security concerns or regression risks identified. The changes are purely additive and affect only visual presentation in the frontend. External test recommendation
AccessibilityThe changes only affect text alignment within the canvas-based data grid (Glide Data Grid) and do not negatively impact accessibility. RecommendationsNo specific recommendations for improvement. The implementation is clean and complete. VerdictAPPROVED: The PR successfully implements the requested feature with excellent test coverage and no backwards compatibility or security issues. This is an automated AI review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR adds an Code QualityThe implementation is clean and follows existing Streamlit patterns:
No maintainability or style issues found. Test CoverageCoverage is good and appropriately layered for this change:
Given the scope (API exposure + renderer behavior), this is adequate. Backwards CompatibilityNo breaking changes identified:
Security & RiskNo security concerns found. External test recommendation
AccessibilityNo new interactive controls or semantics were introduced. Recommendations
VerdictAPPROVED: The changes are coherent, low risk, well tested for the affected behavior, and ready to merge. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR adds an The key changes are:
Column types that use custom or third-party renderers (SelectboxColumn, ListColumn, MultiselectColumn, ProgressColumn, BarChartColumn, LineChartColumn, AreaChartColumn) correctly do not receive the new parameter, as Glide Data Grid's Code QualityThe code is clean, well-structured, and follows existing patterns throughout:
Minor observation (non-blocking): Test CoverageTest coverage is adequate:
The Suggestion (non-blocking): A negative test asserting that an invalid alignment value (e.g., Backwards CompatibilityThis PR is fully backwards compatible:
Security & RiskNo security concerns:
External test recommendation
AccessibilityThe alignment feature itself is accessibility-neutral:
Recommendations
VerdictAPPROVED: A clean, well-tested, backwards-compatible feature that exposes an existing frontend capability through the Python API, with a correct operator precedence bug fix in This is an automated AI review by |
Updates alignment parameter docstrings to explicitly state the default alignment for each column type instead of using generic wording. Also removes the product spec as it's no longer needed. Co-Authored-By: Claude Opus 4.6 <[email protected]>
447c5e9 to
d3030b2
Compare
| width=width, | ||
| help=help, | ||
| pinned=pinned, | ||
| alignment=alignment, |
There was a problem hiding this comment.
question: Do we need to validate this alignment value?
There was a problem hiding this comment.
I think it's somewhat fine to rely on typing for correct input + silently ignoring wrong values in this case. We don't have similar validations for most other column config props. And for other commands, we are also somewhat inconsistently validating if it gets a value different from what is specified in the type and docstring.
Previously, wrong values would have been ignored on the canvas layer, but I added something to already validate and silently ignore this in our frontend logic.
…-alignment Resolved conflict in column_types.py by keeping both the hidden column note from develop and the alignment parameter docstring from this branch. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add parseAlignmentConfig() to validate column alignment configuration. Invalid values now log a console warning and fall back to default alignment instead of being silently ignored by the Canvas 2D API. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Describe your changes
Adds an
alignmentparameter tost.column_config.Columnand all typed column configs (TextColumn, NumberColumn, etc.) that controls horizontal text alignment (left, center, right) of cell content inst.dataframeandst.data_editor.ContentAlignmenttype alias (Literal["left", "center", "right"])alignmentparameter to all 19 column config functionsNone, which preserves existing column-type-specific defaultsThe frontend already supports this via Glide Data Grid's
contentAlignproperty - this PR exposes it in the Python API.The following column types do not support alignment:
SelectboxColumn,ListColumn,MultiselectColumn,BarChartColumn,LineChartColumn,AreaChartColumn,ProgressColumn.GitHub Issue Link (if applicable)
Testing Plan
lib/tests/streamlit/elements/lib/column_types_test.py— Tests alignment parameter on all column typese2e_playwright/st_dataframe_config_test.py— Visual regression test for alignmentProduct Spec
specs/2026-03-11-dataframe-column-alignment/product-spec.mdAgent metrics