SelectPanel
The SelectPanel is an anchored dialog that allows users to quickly navigate and select one or multiple items from a list. It includes a text input for filtering, supports item grouping, and offers a footer for additional actions. Changes are applied upon closing the panel.
Page navigation navigation
React examples
Single-select
Multi-select
When users search for new items, maintain their current selections and use a minimal loading state to indicate ongoing activity.
Grouped items
Items can be grouped to provide additional context or to visually separate them. Each group can have a title for better organization.
Items with leading visuals
Items with dividers
With header
With a footer
An optional footer at the bottom can include a link or button for additional actions.
Loading
Provide visual cues to users when processes may take longer than expected. Use loading states to communicate results are loading. Use when retrieving initial data to prevent users from seeing an empty list.
Other label options
If the button represents the current selection, it must have an associated label, either internally (within the button) or externally (adjacent to the button).
Visually hidden label
Internal label
Custom (external) anchor
To use an external anchor, pass an anchorRef to SelectPanel. You will also need to manually toggle the open prop when activating the custom anchor.
Empty State Message
If no message prop is supplied, a generic default empty state message "No items available" will be automatically used. To ensure that this message is congruent with your SelectPanel implementation, manually configure a custom empty state message. Currently, the default message is displayed both when the SelectPanel is completely empty (no items at all), as well as when no results are found while filtering. You may choose to use conditional logic if necessary to control when your custom empty message will appear, or to display different messages for each empty scenario.
...
<SelectPanel message={
items.length === 0
? {
title: "You haven't created any items yet",
variant: "empty",
body: "Please add or create new items to populate the list.",
}
: undefined
} ...
/>
Props
SelectPanel
| Name | Default | Description |
|---|---|---|
items Required | ItemInput[]A collection of | |
title | "Select an item" or "Select items" | string | React.ReactElementA descriptive title for the panel |
subtitle | string | React.ReactElementWhen provided, a subtitle is displayed below the title | |
onOpenChange Required | ( open: boolean, gesture: | 'anchor-click' | 'anchor-key-press' | 'click-outside' | 'escape' | 'selection' | 'cancel' ) => void | |
placeholder | stringText used in anchor when there are no selected items | |
placeholderText | Filter items | stringText used as placeholder for search input |
inputLabel | Same as placeholderText | stringThe aria-label for the filter input |
aria-label | stringaria-label to attach to the base DOM node of the list | |
filterValue | stringThe current value of the search input | |
selected Required | ItemInput | ItemInput[] | undefinedSpecify the selected item(s) | |
open Required | booleanDetermines whether the overlay portion of the component should be shown or not | |
anchorId | stringAn override to the internal id that will be spread on to the renderAnchor | |
anchorRef | RefObject<HTMLElement>An override to the internal renderAnchor ref that will be used to position the overlay. When renderAnchor is null this can be used to make an anchor that is detached from ActionMenu. An override to the internal ref that will be spread on to the renderAnchor | |
onSelectedChange Required | (selected: ItemInput | ItemInput[]) => voidProvide a callback called when the selected item(s) change | |
onFilterChange | (value: string, e: ChangeEvent<HTMLInputElement>) => voidCallback when the search input changes | |
onCancel | () => void(Narrow screens and variant=modal) Callback when the user hits cancel or close | |
overlayProps | Partial<OverlayProps>See Overlay props. | |
textInputProps | Partial<Omit<TextInputProps, 'onChange'>>See TextInput props. | |
variant | 'anchored' | 'anchored' | 'modal'Anchored by default, SelectPanel can be opened as a modal |
footer Deprecated | null | string | React.ReactElementPlease use |
message | A default empty message is provided if this option is not configured. Supply a custom empty message to override the default. | {title: string | React.ReactElement; variant: 'empty' | 'error' | 'warning'; body: React.ReactNode; icon?:React.ComponentType<IconProps>;action?: React.ReactElement;}Message to display in the panel in case of error or empty results |
notice | {text: string | React.ReactElement; variant: 'empty' | 'error' | 'warning';}Optional notice to display on top of the panel | |
secondaryAction | null | React.ReactElementSecondary action, it will be rendered in the footer of the panel. Use |
showSelectedOptionsFirst | booleanWhether to display the selected items at the top of the list | |
showSelectAll | false | booleanWhen |
disableFullscreenOnNarrow | undefined (uses feature flag default) | booleanWhether to disable fullscreen behavior on narrow viewports. When |
loading | false | booleanWhether the panel is in a loading state. When |
align | 'start' | 'start' | 'end' | 'center'Determines the alignment of the panel relative to the anchor. Defaults to 'start' which aligns the left edge of the panel with the left edge of the anchor. |