Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
✅ PR preview is ready!
|
proto/streamlit/proto/Arrow.proto
Outdated
| // Whether to show borders around the table and between cells | ||
| bool border = 14; |
There was a problem hiding this comment.
It's very annoying/confusing that dataframe, data editor, table, charts, etc, are all reusing this arrow proto message. I think we need to get to a better solution here before adding a lot of new parameters...
There was a problem hiding this comment.
Have been planning to think about a good solution for this. But the main problem is the backwards compatibility that makes it nearly impossible to do any reasonable change here.
There was a problem hiding this comment.
But I'm hoping that we can soon scrape the backwards compatibility (with SiS vnext) and finally do a real refactoring of our protos.
There was a problem hiding this comment.
Hm damn. So no way to move forward with this PR before we do that refactoring?
There was a problem hiding this comment.
Hmm, yeah I think we can move forward. But maybe add some comments that its table only prop.
| ).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it("renders with all borders when border=true", () => { |
There was a problem hiding this comment.
Not sure if we need so many frontend tests here or if it's better to just have the e2e snapshot tests...
There was a problem hiding this comment.
My personal preference is to have e2e tests for style aspects. But probably fine to leave those in.
| Examples | ||
| -------- | ||
| **Example 1: Display a simple dataframe as a static table** | ||
| **Example 1: Display a confusion matrix** |
There was a problem hiding this comment.
Note that I updated the two examples here to show some more real-world use cases for st.table. I think this is important so we differentiate it from st.dataframe. @sfc-gh-dmatthews your call whether we should edit something here. We also need to update the demo apps.
I'd also love to add a 3rd example with border=None that shows how you can use a borderless table for "layout" purposes (e.g. to show some metric names on the left and values on the right side), but I think we first need hide_index and hide_header to make that look good (and ideally hide both by default if there's no information in the index/header), so I left it out for now.
| /** Whether to show borders around the table and between cells. */ | ||
| private readonly _border: Arrow.BorderMode | ||
|
|
There was a problem hiding this comment.
I don't think we want to pass this info through quiver, since quiver should only deal with the arrow data. Instead, it would be better to pass in the full element the same way as its done with the dataframe here:
streamlit/frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx
Lines 417 to 418 in 2360acc
which needs a bit refactoring by moving the current element prop to data and adding a new element prop that has the full proto message.
There was a problem hiding this comment.
✅ Done, I refactored it so it doesn't use Quiver anymore. I also cross-checked with the dataframe implementation that the refactored part uses the same structure but would be great if you could give this another quick look.
| borderRadius: theme.radii.default, | ||
| overflow: "auto", | ||
| })) | ||
| export const StyledTableBorder = styled.div<{ $border: Arrow.BorderMode }>( |
There was a problem hiding this comment.
Was there a specific reason why you used $ as a prefix? Did the browser complain? I believe it's to prevent the property from being forwarded to an HTML property with the same name.
There was a problem hiding this comment.
✅ I don't remember anymore but I changed everything to use borderMode / border_mode now (except for the public Python API), then we don't run into these conflicts + it's more consistent with the ArrowProto.BorderMode type + it's more similar to what we do for selection mode / editing mode.
lukasmasuch
left a comment
There was a problem hiding this comment.
Overall LGTM, but the aspect with how the border info is passed in needs a change.
There was a problem hiding this comment.
Pull Request Overview
This PR adds a border parameter to st.table that allows users to control how table borders are displayed. The parameter accepts True (all borders), False (no borders), or "horizontal" (only horizontal borders between rows).
- Adds new
BorderModeenum to the Arrow protobuf with three values: ALL, NONE, and HORIZONTAL - Implements border parsing and validation logic in the Python backend
- Updates frontend components to conditionally render borders and adjust padding/alignment based on the border mode
Reviewed Changes
Copilot reviewed 9 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| proto/streamlit/proto/Arrow.proto | Adds BorderMode enum and border_mode field to Arrow message |
| lib/streamlit/elements/arrow.py | Implements border parameter parsing and adds it to st.table function |
| lib/tests/streamlit/elements/arrow_table_test.py | Adds unit tests for border parameter validation and proto mapping |
| frontend/lib/src/components/elements/ArrowTable/ArrowTable.tsx | Updates component to accept and use border mode for rendering logic |
| frontend/lib/src/components/elements/ArrowTable/ArrowTable.test.tsx | Adds frontend tests for different border modes |
| frontend/lib/src/components/elements/ArrowTable/styled-components.ts | Implements conditional CSS styling based on border mode |
| frontend/lib/src/components/core/Block/ElementNodeRenderer.tsx | Updates element renderer to pass Arrow proto to ArrowTable component |
| e2e_playwright/st_table.py | Adds examples showcasing the new border parameter |
| e2e_playwright/st_table_test.py | Updates test to account for additional table elements |
lukasmasuch
left a comment
There was a problem hiding this comment.
LGTM 👍 a couple of comments

Describe your changes
Adds a
borderparameter tost.table, which allows creating different table styles:Demo app to show it in combination with other
st.tablefeatures:GitHub Issue Link (if applicable)
Closes #11795
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.