Add key-value list example for st.table#14474
Conversation
Add docstring example showing st.table with Material Icons and markdown badges for displaying key-value data with mixed content. Addresses #13185 Co-Authored-By: Claude Opus 4.6 <[email protected]>
✅ 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!
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
There was a problem hiding this comment.
Pull request overview
Adds a user-facing example (docstring) and E2E demo scenario showing how st.table can be used to display rich key-value metadata (icons + markdown badges) with horizontal borders and content-fit width—helping address the “description list / key-value display” use case from #13185 using existing st.table capabilities.
Changes:
- Added a new
st.tabledocstring example for key-value data with Material icons + colored markdown badges. - Added an E2E demo section rendering the same key-value + mixed-markdown table.
- Updated the E2E snapshot test’s expected table element count.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/streamlit/elements/table.py |
Adds a new docstring example demonstrating key-value metadata tables with badges and layout options. |
e2e_playwright/st_table.py |
Adds a new demo section rendering a key-value table with mixed markdown content for E2E snapshots. |
e2e_playwright/st_table_test.py |
Updates the expected count of rendered stTable elements for snapshot testing. |
The count was incorrectly set to 50 when only 48 st.table() calls exist in st_table.py (47 original + 1 new key-value badges demo). Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Summary
This PR adds a new docstring example (Example 6) to st.table demonstrating key-value data display with Material Icons, colored Markdown badges, horizontal borders, and content-fit width. A corresponding demo scenario is added to the E2E app script (e2e_playwright/st_table.py), and the element count constant in the E2E test is updated.
Code Quality
The code is clean and follows existing patterns well. The docstring example uses the same >>> doctest style and .. output:: directive as the other five examples. The E2E demo data mirrors the docstring exactly, with a clear comment. No structural or maintainability issues.
Test Coverage
The existing E2E snapshot test (test_table_rendering) will automatically cover the new table since it iterates over all stTable elements. No new unit tests are needed — this is purely a documentation and demo addition with no behavioral changes. However, the TOTAL_TABLE_ELEMENTS constant is set incorrectly (see inline comment), which will cause the E2E suite to fail.
Backwards Compatibility
No breaking changes. This PR only adds a docstring example and E2E demo data. No API signatures, runtime behavior, or protobuf definitions are modified.
Security & Risk
No security concerns. Changes are limited to a docstring and E2E test files. No new dependencies, no backend logic changes, no network calls, no user input handling, and no frontend code modifications.
External test recommendation
- Recommend external_test: No
- Triggered categories: None
- Evidence:
lib/streamlit/elements/table.py: Docstring-only change (new example added)e2e_playwright/st_table.py: Static E2E demo data additione2e_playwright/st_table_test.py: Element count constant update only
- Suggested external_test focus areas: None
- Confidence: High
- Assumptions and gaps: None. All changes are documentation and demo-only; no runtime, networking, auth, embedding, or serving behavior is affected.
Accessibility
No frontend code changes are introduced, so accessibility is not affected.
Recommendations
- Fix
TOTAL_TABLE_ELEMENTScount ine2e_playwright/st_table_test.py: The constant was changed from 47 to 50, but only one newst.table()call was added (verified: 48 total calls via grep). The correct value is 48. This will cause E2E test failures as-is.
Reviewer agreement
All three reviewers (claude-4.6-opus-high-thinking, gemini-3.1-pro, gpt-5.3-codex-high) agreed that the PR is well-structured, follows existing patterns, has no security or backwards-compatibility concerns, and does not require external tests. Two of three reviewers (claude-4.6-opus-high-thinking, gemini-3.1-pro) independently identified the incorrect TOTAL_TABLE_ELEMENTS count as a blocking issue. One reviewer (gpt-5.3-codex-high) approved the PR without catching this bug — the consolidation review confirms the count is indeed wrong (48 st.table calls, not 50).
Missing reviews
None — all three expected models (gpt-5.3-codex-high, gemini-3.1-pro, claude-4.6-opus-high-thinking) completed their reviews.
Verdict
CHANGES REQUESTED: The TOTAL_TABLE_ELEMENTS count in e2e_playwright/st_table_test.py is incorrect (50 instead of 48), which will cause E2E test failures. The docstring and demo additions are otherwise well-written and follow existing conventions.
Consolidated review by claude-4.6-opus-high-thinking from 3 individual reviews (claude-4.6-opus-high-thinking, gemini-3.1-pro, gpt-5.3-codex-high).
This review also includes 1 inline comment(s) on specific code lines.
## Describe your changes Automated snapshot updates for #14474 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:** 3 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]>
|
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 |
There was a problem hiding this comment.
Summary
This PR adds a new docstring example (Example 6) to st.table demonstrating key-value data with Material Icons and colored Markdown badges, along with a corresponding e2e demo and snapshot baselines. The changes are documentation and test-only — no backend logic, frontend code, or protobuf definitions are modified.
Changed files:
lib/streamlit/elements/table.py— New docstring example block (Example 6)e2e_playwright/st_table.py— New table demo appended to the e2e appe2e_playwright/st_table_test.py—TOTAL_TABLE_ELEMENTSbumped from 47 to 48- Three new snapshot images for chromium/firefox/webkit
Code Quality
The changes are clean and follow existing patterns within the file:
- The docstring example uses the same
>>>/...doctest format as Examples 1–5 and includes the.. output::directive with a well-named URL. - The e2e app appends the new table at the end, preserving all existing element indices and minimizing churn.
- The
TOTAL_TABLE_ELEMENTSconstant is correctly updated to 48.
Reviewer disagreement on docstring format: One reviewer (gemini-3.1-pro) flagged that lib/streamlit/AGENTS.md recommends .. code-block:: python for examples and requested the change. The other two reviewers (claude-4.6-opus-high-thinking, gpt-5.3-codex-high) approved without raising this. After verification: all five existing examples in table.py use the >>> format, and the >>> style dominates across lib/streamlit/elements/ (hundreds of occurrences vs ~17 for .. code-block::). The AGENTS.md guidelines also state "Follow existing patterns," which creates tension with the .. code-block:: recommendation. Converting only this example would introduce inconsistency within the file. A whole-file (or codebase-wide) migration would be the appropriate way to address this, ideally in a separate PR.
Test Coverage
Coverage is adequate for the scope:
- The new table element (index 47) is automatically covered by the existing
test_table_renderingsnapshot loop. - Three required snapshot baselines (chromium, firefox, webkit) are included.
- No additional unit tests are needed since no runtime logic was changed.
All three reviewers agreed on this assessment.
Backwards Compatibility
No breaking changes. This PR only adds a new docstring example and e2e test case. No existing APIs, behavior, or test assertions are modified — all existing nth() indices remain correct since the new element is appended at the end.
All three reviewers agreed.
Security & Risk
No security concerns. The changes are purely documentation and test additions with no modifications to server endpoints, authentication, session handling, file serving, HTML/Markdown sanitization, dependencies, or runtime code paths.
All three reviewers agreed.
External test recommendation
- Recommend external_test: No
- Triggered categories: None
- Evidence:
lib/streamlit/elements/table.py: Docstring-only addition; no logic changese2e_playwright/st_table.py: New test app entry; no routing/auth/embedding changese2e_playwright/st_table_test.py: Element count bump only- Snapshot images: Baseline additions only
- Suggested external_test focus areas: N/A
- Confidence: High
- Assumptions and gaps: None. Changes are fully contained in documentation and test demo code with zero runtime logic impact.
All three reviewers agreed.
Accessibility
No frontend component changes are introduced. The demo uses Material Icons and badge syntax already supported by the existing st.table implementation. No new accessibility considerations apply.
All three reviewers agreed.
Recommendations
- (Low priority) Consider migrating all
st.tabledocstring examples from>>>to.. code-block:: pythonformat in a follow-up PR to align with theAGENTS.mdguidelines, rather than changing only the new example and introducing within-file inconsistency.
Verdict
APPROVED: Clean, low-risk, documentation-only PR that adds a useful st.table docstring example and corresponding e2e demo. All three reviewers agree on the substance; the only point of contention (docstring format style) is a non-blocking nit best addressed in a separate migration effort.
Consolidated AI review by claude-4.6-opus-high-thinking, synthesizing reviews from claude-4.6-opus-high-thinking, gemini-3.1-pro, and gpt-5.3-codex-high.
This review also includes 1 inline comment(s) on specific code lines.
st.table
| https://doc-table-minimal.streamlit.app/ | ||
| height: 150px | ||
|
|
||
| **Example 6: Display key-value data with badges** |
There was a problem hiding this comment.
@lukasmasuch Do we really want two examples of key-value pair display? Would it be better to just update the first one if you want to show badges?
There was a problem hiding this comment.
Yeah, good point. I will merge those into one

Describe your changes
Adds a docstring example and e2e demo showing
st.tablewith key-value data using::material/folder:,:material/code:, etc.):green-badge[...],:blue-badge[...], etc.)border="horizontal")width="content")This provides users with a practical example of displaying rich key-value metadata in tables.
GitHub Issue Link (if applicable)
Testing Plan
make check)make debugAgent metrics