Skip to content

Add key-value list example for st.table#14474

Merged
lukasmasuch merged 3 commits intodevelopfrom
lukasmasuch/table-kv-badges-demo
Mar 25, 2026
Merged

Add key-value list example for st.table#14474
lukasmasuch merged 3 commits intodevelopfrom
lukasmasuch/table-kv-badges-demo

Conversation

@lukasmasuch
Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch commented Mar 23, 2026

Describe your changes

Adds a docstring example and e2e demo showing st.table with key-value data using:

  • Material Icons as key prefixes (:material/folder:, :material/code:, etc.)
  • Markdown badges with colors (:green-badge[...], :blue-badge[...], etc.)
  • Horizontal borders (border="horizontal")
  • Content-fit width (width="content")

This provides users with a practical example of displaying rich key-value metadata in tables.

GitHub Issue Link (if applicable)

Testing Plan

  • Python unit tests pass (make check)
  • Demo verified with make debug
Agent metrics
Type Name Count
skill checking-changes 1
subagent fixing-pr 1
subagent general-purpose 2

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]>
Copilot AI review requested due to automatic review settings March 23, 2026 19:54
@lukasmasuch lukasmasuch added impact:users PR changes affect end users change:docs PR contains documentation change labels Mar 23, 2026
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Mar 23, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@lukasmasuch lukasmasuch added the ai-review If applied to PR or issue will run AI review workflow label Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-14474/streamlit-1.55.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-14474.streamlit.app (☁️ Deploy here if not accessible)

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.table docstring 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]>
@github-actions github-actions bot removed the ai-review If applied to PR or issue will run AI review workflow label Mar 23, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 addition
    • e2e_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

  1. Fix TOTAL_TABLE_ELEMENTS count in e2e_playwright/st_table_test.py: The constant was changed from 47 to 50, but only one new st.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.

@github-actions github-actions bot added the do-not-merge PR is blocked from merging label Mar 23, 2026
@lukasmasuch lukasmasuch added the update-snapshots Trigger snapshot autofix workflow label Mar 23, 2026
@github-actions github-actions bot removed the update-snapshots Trigger snapshot autofix workflow label Mar 23, 2026
@lukasmasuch lukasmasuch added the update-snapshots Trigger snapshot autofix workflow label Mar 23, 2026
## 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]>
@lukasmasuch lukasmasuch removed the update-snapshots Trigger snapshot autofix workflow label Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Snapshot Autofix Failed

The snapshot autofix workflow could not update snapshots. This can happen if:

  • The Playwright E2E tests passed (no snapshot mismatches to fix)
  • No Playwright workflow run was found for the current commit
  • The snapshot artifacts could not be downloaded

Please check the workflow run logs for details.

If you need to update snapshots manually, you can:

  1. Download the snapshot artifacts from the failed Playwright workflow run
  2. Extract them to e2e_playwright/__snapshots__/
  3. Commit and push the changes

You can re-run this workflow by removing and re-adding the update-snapshots label.

@lukasmasuch lukasmasuch added the ai-review If applied to PR or issue will run AI review workflow label Mar 23, 2026
@github-actions github-actions bot removed the ai-review If applied to PR or issue will run AI review workflow label Mar 23, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 app
  • e2e_playwright/st_table_test.pyTOTAL_TABLE_ELEMENTS bumped 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_ELEMENTS constant 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_rendering snapshot 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 changes
    • e2e_playwright/st_table.py: New test app entry; no routing/auth/embedding changes
    • e2e_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

  1. (Low priority) Consider migrating all st.table docstring examples from >>> to .. code-block:: python format in a follow-up PR to align with the AGENTS.md guidelines, 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.

@github-actions github-actions bot removed the do-not-merge PR is blocked from merging label Mar 23, 2026
@lukasmasuch lukasmasuch added change:docs PR contains documentation change and removed change:docs PR contains documentation change labels Mar 23, 2026
@lukasmasuch lukasmasuch changed the title Add key-value badges demo for st.table Add key-value list example for st.table Mar 24, 2026
Copy link
Copy Markdown
Collaborator

@sfc-gh-lwilby sfc-gh-lwilby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lukasmasuch lukasmasuch merged commit fbb36d1 into develop Mar 25, 2026
68 of 71 checks passed
@lukasmasuch lukasmasuch deleted the lukasmasuch/table-kv-badges-demo branch March 25, 2026 16:39
https://doc-table-minimal.streamlit.app/
height: 150px

**Example 6: Display key-value data with badges**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point. I will merge those into one

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prepared a PR here: #14551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:docs PR contains documentation change impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants