MultiChoice#

Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).


import panel as pn
pn.extension()

The MultiChoice widget allows selecting multiple values from a list of options. It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the MultiSelect, CrossSelector, CheckBoxGroup and CheckButtonGroup widgets. The MultiChoice widget provides a much more compact UI than MultiSelect.

Discover more on using widgets to add interactivity to your applications in the how-to guides on interactivity. Alternatively, learn how to set up callbacks and (JS-)links between parameters or how to use them as part of declarative UIs with Param.

Parameters:#

For details on other options for customizing the component see the layout and styling how-to guides.

Core#

  • options (list or dict): List or dictionary of options

  • max_items (int): Maximum number of options that can be selected

  • value (list): Currently selected option values

Display#

  • delete_button (boolean): Whether to display a button to delete a selected option

  • disabled (boolean): Whether the widget is editable

  • name (str): The title of the widget

  • option_limit (int): Maximum number of options to display at once.

  • search_option_limit (int): Maximum number of options to display at once if search string is entered.

  • placeholder (str): String displayed when no selection has been made.

  • solid (boolean): Whether to display widget with solid or light style.


multi_choice = pn.widgets.MultiChoice(name='MultiSelect', value=['Apple', 'Pear'],
    options=['Apple', 'Banana', 'Pear', 'Strawberry'])

pn.Column(multi_choice, height=200)

MultiChoice.value returns a list of the currently selected options:

multi_choice.value
['Apple', 'Pear']

The solid option controls the style of the widget:

pn.Column(multi_choice.clone(solid=False), height=200)

Controls#

The MultiChoice widget exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:

pn.Row(multi_choice.controls(jslink=True), multi_choice)

Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).