Configure a multiselect column in st.dataframe or st.data_editor.
This command needs to be used in the column_config parameter of st.dataframe or st.data_editor. When used with st.data_editor, users can select options from a dropdown menu. You can configure the column to allow freely typed options, too.
You can also use this column type to display colored labels in a read-only st.dataframe.
Note
Editing for non-string or mixed type lists can cause issues with Arrow serialization. We recommend that you disable editing for these columns or convert all list values to strings.
Function signature[source] | |
---|---|
st.column_config.MultiselectColumn(label=None, *, width=None, help=None, disabled=None, required=None, default=None, options=None, accept_new_options=None, color=None, format_func=None) | |
Parameters | |
label (str or None) | The label shown at the top of the column. If None (default), the column name is used. |
width ("small", "medium", "large", or None) | The display width of the column. If this is None (default), the column will be sized to fit the cell contents. Otherwise, this can be one of the following:
If the total width of all columns is less than the width of the dataframe, the remaining space will be distributed evenly among all columns. |
help (str or None) | A tooltip that gets displayed when hovering over the column label. If this is None (default), no tooltip is displayed. The tooltip can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the body parameter of st.markdown. |
disabled (bool or None) | Whether editing should be disabled for this column. Defaults to False. |
required (bool or None) | Whether edited cells in the column need to have a value. If True, an edited cell can only be submitted if it has a value other than None. Defaults to False. |
default (Iterable of str or None) | Specifies the default value in this column when a new row is added by the user. |
options (Iterable of str or None) | The options that can be selected during editing. |
accept_new_options (bool or None) | Whether the user can add selections that aren't included in options. If this is False (default), the user can only select from the items in options. If this is True, the user can enter new items that don't exist in options. When a user enters and selects a new item, it is included in the returned cell list value as a string. The new item is not added to the options drop-down menu. |
color (str, Iterable of str, or None) | The color to use for different options. This can be:
|
format_func (function or None) | Function to modify the display of the options. It receives the raw option defined in options as an argument and should output the label to be shown for that option. When used in st.data_editor, this has no impact on the returned value. If this is None (default), the raw option is used as the label. |
Examples
Example 1: Editable multiselect column
To customize the label colors, provide a list of colors to the color parameter. You can also format the option labels with the format_func parameter.
Example 2: Colored tags for st.dataframe
When using st.dataframe, the multiselect column is read-only and can be used to display colored tags. In this example, the dataframe uses the primary theme color for all tags.
Still have questions?
Our forums are full of helpful information and Streamlit experts.