CheckPicker

Used for multiple data selection, support grouping.

Import

import { CheckPicker } from 'rsuite';

Examples

Basic

With a label

Appearance

Size

Sticky

Set the sticky property to put the selected in the options to the top.

Block

Loading state

When the picker is loading, a spinner is displayed to indicate the loading state. Clicking a loading picker won't open its options menu.

Group

Placement and Prevent overflow

Custom options

Disabled and read only

Customize a select all function.

Async

Controlled

Virtualize Long Lists

Responsive

Accessibility

ARIA properties

  • CheckPicker has role combobox.
  • Has the aria-haspopup="listbox" attribute to indicate that the combobox has a popup listbox.
  • Has the aria-expanded attribute to indicate whether the listbox is open or not.
  • Has the aria-controls attribute to indicate the ID of the listbox element.
  • Has the aria-activedescendant attribute to indicate the ID of the focused option.
  • When label is set, the aria-labelledby attribute is added to the combobox element and the listbox element and is set to the value of the id attribute of label.
  • listbox has the aria-multiselectable=true attribute to indicate that the listbox is multi-selectable.

Keyboard interactions

  • - Move focus to the next option.
  • - Move focus to the previous option.
  • Enter - Select the focused option.
  • Esc - Close the listbox.

Props

<CheckPicker>

Property Type(Default) Description
appearance 'default' | 'subtle' ('default') Set picker appearence
block boolean Whether to display the component as a block
caretAs ElementType Custom component for the caret icon
classPrefix string ('picker') The prefix for the component CSS class
cleanable boolean (true) Whether the selected value can be cleared
container HTMLElement | (() => HTMLElement) Sets the rendering container
countable boolean (true) Whether to display the count of selected items
data * Option[] The data for the component
defaultValue Value Default values of the selected items
disabled boolean Whether the component is disabled
disabledItemValues Value Values of items to be disabled
groupBy string Key for grouping data items
label ReactNode Label displayed at the beginning of the toggle button
labelKey string ('label') Key for the label in the data items
listboxMaxHeight number (320) Maximum height of the listbox
listProps ListProps Properties for virtualized lists
loading boolean (false) Whether to display a loading state indicator
locale PickerLocaleType Localization settings for component text
onChange (value: Value, event) => void Callback fired when value changes
onClean (event) => void Callback fired when value is cleared
onClose () => void Callback fired when component closes
onEnter () => void Callback fired before the overlay transitions in
onEntered () => void Callback fired after the overlay finishes transitioning in
onEntering () => void Callback fired as the overlay begins to transition in
onExit () => void Callback fired right before the overlay transitions out
onExited () => void Callback fired after the overlay finishes transitioning out
onExiting () => void Callback fired as the overlay begins to transition out
onGroupTitleClick (event) => void Callback fired when a group title is clicked
onOpen () => void Callback fired when component opens
onSearch (search:string, event) => void Callback fired when search is performed
onSelect (value: Value, item: Option , event) => void Callback fired when an item is selected
open boolean Whether the component is open
placeholder ReactNode ('Select') Placeholder text
placement Placement('bottomStart') The placement of the component
popupClassName string Custom class name for the popup
popupStyle CSSProperties Custom style for the popup
preventOverflow boolean Prevent floating element overflow
renderExtraFooter () => ReactNode Custom render function for extra footer
renderListbox (listbox:ReactNode) => ReactNode Custom render function for listbox
renderOption (label: ReactNode, item:Option) => ReactNode Custom render function for options
renderOptionGroup (title: ReactNode, item:Option) => ReactNode Custom render function for option groups
renderValue (value: Value, items: Option[], selected:ReactNode) => ReactNode Custom render function for selected items
searchable boolean (true) Whether to display search input box
searchBy (keyword: string, label: ReactNode, item: Option) => boolean Custom search function
size 'lg' | 'md' | 'sm' | 'xs' ('md') Size of the picker
sort (isGroup: boolean) => (a: any, b: any) => number Custom sort function for options
sticky boolean Whether to stick selected options at the top
toggleAs ElementType ('a') Custom element type for the component
value Value Values of the selected items (Controlled)
valueKey string ('value') Key for the value in the data items
virtualized boolean Whether to use virtualized list

Option

interface Option<V> {
  /** The value of the option corresponds to the `valueKey` in the data. **/
  value: V;

  /** The content displayed by the option corresponds to the `labelKey` in the data. **/
  label: ReactNode;

  /**
   * The data of the child option corresponds to the `childrenKey` in the data.
   * Properties owned by tree structure components, such as TreePicker, Cascader.
   */
  children?: Option<V>[];

  /**
   * Properties of grouping functional components, such as CheckPicker, InputPicker
   */
  groupBy?: string;

  /**
   * The children under the current node are loading.
   * Used for components that have cascading relationships and lazy loading of children. E.g. Cascader, MultiCascader
   */
  loading?: boolean;
}

Placement

type Placement =
  | 'bottomStart'
  | 'bottomEnd'
  | 'topStart'
  | 'topEnd'
  | 'leftStart'
  | 'leftEnd'
  | 'rightStart'
  | 'rightEnd'
  | 'auto'
  | 'autoVerticalStart'
  | 'autoVerticalEnd'
  | 'autoHorizontalStart'
  | 'autoHorizontalEnd';

ListProps

interface ListProps {
  /**
   * Size of a item in the direction being windowed.
   */
  itemSize?: number | ((index: number) => number);

  /**
   * Scroll offset for initial render.
   */
  initialScrollOffset?: number;

  /**
   * Called when the items rendered by the list change.
   */
  onItemsRendered?: (props: ListOnItemsRenderedProps) => void;

  /**
   * Called when the list scroll positions changes, as a result of user scrolling or scroll-to method calls.
   */
  onScroll?: (props: ListOnScrollProps) => void;
}

Value

type Value = (string | number)[];