SelectPicker

For a single data selection, support grouping.

Import

import { SelectPicker } from 'rsuite';

// or
import SelectPicker from 'rsuite/SelectPicker';

Examples

Default

Appearance

Size

Block

Group

Tip: When set to auto*, try to scroll the page, or change the browser size, it will automatically appear in the right place.

Custom Option

Disabled and read only

Async

Container and prevent overflow

Controlled

Accessibility

Learn more in Accessibility.

Props

<SelectPicker>

Property Type (Default) Description
appearance 'default' | 'subtle' ('default') Set picker appearence
block boolean Blocking an entire row
classPrefix string ('picker') The prefix of the component CSS class
cleanable boolean (true) Whether the option can be emptied.
container HTMLElement | (() => HTMLElement) Sets the rendering container
data * ItemDataType[] Selectable data
defaultValue ValueType Default value
disabled boolean Whether or not component is disabled
disabledItemValues ValueType[] Disable optional
groupBy string Set grouping criteria 'key' in 'data'
labelKey string ('label') Set options to display the 'key' in 'data'
listProps ListProps List-related properties in react-virtualized
locale PickerLocaleType Locale text
menuMaxHeight number (320) Set the max height of the Dropdown
menuClassName string A css class to apply to the Menu DOM node.
menuStyle CSSProperties A style to apply to the Menu DOM node.
onChange (value: ValueType, event) => void callback function when value changes
onClean (event) => void Callback fired when value clean
onClose () => void Close callback functions
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 Click the callback function for the group header
onOpen () => void Open callback function
onSearch (searchKeyword: string, event) => void callback function for Search
onSelect (value: ValueType, item: ItemDataType, event) => void option is clicked after the selected callback function
open boolean Whether open the component
placeholder ReactNode ('Select') Setting placeholders
placement Placement('bottomStart') The placement of component
preventOverflow boolean Prevent floating element overflow
renderExtraFooter () => ReactNode custom render extra footer
renderMenu (menu:ReactNode) => ReactNode Customizing the Rendering Menu list
renderMenuGroup (groupTitle:ReactNode, item: ItemDataType) => ReactNode Custom Render Options Group
renderMenuItem (label:ReactNode, item: ItemDataType) => ReactNode Custom Render Options
renderValue (value: ValueType, item: ItemDataType, selectedElement:ReactNode) => ReactNode Custom Render selected options
searchBy (keyword:string, label:ReactNode, item: ItemDataType) => boolean Custom search rules
searchable boolean (true) Whether you can search for options.
size 'lg' | 'md' | 'sm' | 'xs' ('md') A picker can have different sizes
sort (isGroup: boolean) => (a: any, b: any) => number Sort options
toggleAs ElementType ('a') You can use a custom element for this component
value ValueType Value (Controlled)
valueKey string ('value') Set option value 'key' in 'data'
virtualized boolean Whether using Virtualized List
caretAs ElementType Custom component for the caret icon

ts:ItemDataType

interface ItemDataType {
  /** The value of the option corresponds to the `valueKey` in the data. **/
  value: string;

  /** 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?: ItemDataType[];

  /**
   * 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;
}

ts:Placement

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

ts:ValueType

type ValueType = string | number;