Skip to content

Add MultiselectColumn for st.dataframe and st.data_editor#9223

Merged
lukasmasuch merged 85 commits intodevelopfrom
feature/multiselect-column-2
Aug 22, 2025
Merged

Add MultiselectColumn for st.dataframe and st.data_editor#9223
lukasmasuch merged 85 commits intodevelopfrom
feature/multiselect-column-2

Conversation

@lukasmasuch
Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch commented Aug 6, 2024

Describe your changes

Adds a new column type - st.column_config.MultiSelectColumn - that allows a selection of multiple predefined options.

image

Examples:

import pandas as pd
import streamlit as st

data_df = pd.DataFrame(
    {
        "category": [
            ["exploration", "visualization"],
            ["llm", "visualization"],
            ["exploration"],
        ],
    }
)

st.data_editor(
    data_df,
    column_config={
        "category": st.column_config.MultiselectColumn(
            "App Categories",
            options=[
                "exploration",
                "visualization",
                "llm",
            ],
            color=["orange", "red", "#ffc38a"],
            format_func=lambda x: x.capitalize(),
        ),
    },
)

# Or use it for colored tags in a read-only dataframe:

st.dataframe(
    data_df,
    column_config={
        "category": st.column_config.MultiselectColumn(
            "App Categories",
            options=["exploration", "visualization", "llm"],
            color=["orange", "red", "#ffc38a"],
            format_func=lambda x: x.capitalize(),
        ),
    },
)

GitHub Issue Link (if applicable)

Testing Plan

  • Added unit & e2e tests.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@lukasmasuch lukasmasuch marked this pull request as draft August 6, 2024 21:06
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@lukasmasuch lukasmasuch added security-assessment-completed impact:internal PR changes only affect internal code change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users and removed impact:internal PR changes only affect internal code labels Sep 26, 2024
@kenho811
Copy link
Copy Markdown

bump

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Oct 14, 2024
@lukasmasuch lukasmasuch removed the stale label Oct 14, 2024
@lukasmasuch lukasmasuch added the do-not-merge PR is blocked from merging label Oct 23, 2024
@MiguelMygon
Copy link
Copy Markdown

bump

@arkpope
Copy link
Copy Markdown

arkpope commented Jan 4, 2025

Any updates on this? I am happy to fix this if that's the hold up.

@arkpope
Copy link
Copy Markdown

arkpope commented Feb 1, 2025

@lukasmasuch I am happy to generate tests and work on this, is there a blocker to that? Thanks

@lukasmasuch lukasmasuch changed the title [WIP] Multi-select column [WIP] Add MultiselectColumn for st.dataframe and st.data_editor Aug 21, 2025
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just some drive-by fixes to use the new width parameter instead of use_container_width in tests.

@sfc-gh-lmasuch sfc-gh-lmasuch requested a review from Copilot August 21, 2025 11:48
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

This PR adds a new MultiselectColumn column type for st.dataframe and st.data_editor, enabling users to display and edit multiple selections from predefined options with colored labels. This addresses feature requests for multiselect functionality in dataframes similar to existing single selectbox columns.

Key changes:

  • Implements complete multiselect column functionality with support for colors, formatting, and option validation
  • Adds comprehensive test coverage including unit tests and E2E tests
  • Updates existing E2E test files to use new width parameter instead of deprecated use_container_width

Reviewed Changes

Copilot reviewed 19 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/streamlit/elements/lib/column_types.py Implements MultiselectColumn function and supporting TypedDict classes
lib/streamlit/column_config.py Exports the new MultiselectColumn in the public API
lib/streamlit/elements/lib/column_config_utils.py Adds multiselect column data kind mappings
frontend/lib/src/components/widgets/DataFrame/columns/MultiselectColumn.ts Frontend TypeScript implementation of multiselect column functionality
frontend/lib/src/components/widgets/DataFrame/columns/index.ts Registers the new multiselect column type
lib/tests/streamlit/elements/lib/column_types_test.py Unit tests for the Python multiselect column implementation
frontend/lib/src/components/widgets/DataFrame/columns/MultiselectColumn.test.ts Frontend unit tests for multiselect column
e2e_playwright/st_dataframe_config.py Adds multiselect column to E2E test configurations
Multiple E2E test files Updates to use new width parameter instead of use_container_width
Comments suppressed due to low confidence (1)

@lukasmasuch lukasmasuch marked this pull request as ready for review August 21, 2025 11:50
@lukasmasuch lukasmasuch changed the title [WIP] Add MultiselectColumn for st.dataframe and st.data_editor Add MultiselectColumn for st.dataframe and st.data_editor Aug 21, 2025
Comment on lines +141 to +144
const uniqueOptions = uniqBy(
preparedOptions.map(opt => opt.value),
(x: string) => x
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

suggestion: Utilize a Set here for uniqueness guarantees and performance (will also need to update the .includes to .has below)

  const uniqueOptions = new Set(preparedOptions.map(opt => opt.value))

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.

Updated 👍

@lukasmasuch lukasmasuch enabled auto-merge (squash) August 22, 2025 18:06
@lukasmasuch lukasmasuch disabled auto-merge August 22, 2025 18:27
@lukasmasuch lukasmasuch enabled auto-merge (squash) August 22, 2025 18:27
@lukasmasuch lukasmasuch merged commit 2d4d81c into develop Aug 22, 2025
37 checks passed
@lukasmasuch lukasmasuch deleted the feature/multiselect-column-2 branch August 22, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data Editor: add multi-select column Option to apply colours to ListColumn items

9 participants