CheckTreePicker
CheckTreePicker are supported in multiple selectors for multiple selection of complex data structures.
Import
import { CheckTreePicker } from 'rsuite';
Examples
Basic
Appearance
Size
Cascade
The cascade attribute can set whether or not CheckTreePicker can consider the cascade relationship of the parent parent when selecting. The default value is true.
Placement
Disabled and read only
Custom options
Async
Extra footer
Accessibility
ARIA properties
- CheckTreePicker has role
combobox
. - Has the
aria-haspopup="tree"
attribute to indicate that the combobox has a popup tree. - Has the
aria-expanded
attribute to indicate whether the tree is open or not. - Has the
aria-controls
attribute to indicate the ID of the tree element. - Has the
aria-activedescendant
attribute to indicate the ID of the focused tree node. - When
label
is set, thearia-labelledby
attribute is added to the combobox element and the tree element and is set to the value of theid
attribute oflabel
. - The tree has the
aria-multiselectable=true
attribute to indicate that the tree is multi-selectable.
Keyboard interactions
- ↓ - Move focus to the next tree node.
- ↑ - Move focus to the previous tree node.
- → - Expand the focused tree node if it is collapsed.
- ← - Collapse the focused tree node if it is expanded.
- Enter - Select the focused tree node.
- Esc - Close the tree.
Props
<CheckTreePicker>
Property | Type (Default) |
Description |
---|---|---|
appearance | 'default' | 'subtle' ('default') |
Set picker appearence |
block | boolean | Blocking an entire row |
caretAs | ElementType | Custom component for the caret icon |
cascade | boolean | whether cascade select |
childrenKey | string ('children') |
set children key in data |
cleanable | boolean (true) |
whether the selected value can be cleared |
container | HTMLElement | (() => HTMLElement) | Sets the rendering container |
countable | boolean (true) |
whether display counts of checkItems |
data * | TreeNode[] | tree data |
defaultExpandAll | boolean | expand all tree node |
defaultExpandItemValues | string[] | Set the value of the default expanded node |
defaultValue | string[] | (UnControlled) default values of the selected tree node |
disabled | boolean | Whether to disable Picker |
disabledItemValues | string[] | Disable item by value |
expandItemValues | string[] | Set the value of the expanded node (controlled) |
getChildren | (item: TreeNode) => Promise<TreeNode> | load node children data asynchronously |
number | ⚠️[Deprecated] Use treeHeight instead |
|
labelKey | string ('label') |
set label key in data |
listProps | ListProps | Properties of virtualized lists. |
loading | boolean (false) |
Whether to display a loading state indicator |
locale | PickerLocaleType | Locale text |
string | ⚠️[Deprecated] Use popupClassName instead |
|
CSSProperties | ⚠️[Deprecated] Use popupStyle instead |
|
onChange | (values:string[]) => void | Callback fired when value change |
onClean | (event:SyntheticEvent) => void | Callback fired when value clean |
onClose | () => void | Callback fired when close component |
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 |
onExpand | (expandItemValues: string[], item: TreeNode, concat:(data, children) => Array) => void | Callback fired when tree node expand state changed |
onOpen | () => void | Callback fired when open component |
onSearch | (searchKeyword:string, event) => void | Callback fired when search |
onSelect | (item:TreeNode, value:string, event) => void | Callback fired when tree node is selected |
open | boolean | Whether open the component |
placeholder | ReactNode ('Select') |
Setting placeholders |
placement | Placement ('bottomStart') |
Placement of 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 extra footer |
renderMenu | (menu:ReactNode) => ReactNode | Customizing the Rendering Menu list |
renderTreeIcon | (item:TreeNode) => ReactNode | Custom render the icon of tree node |
renderTreeNode | (item:TreeNode) => ReactNode | Custom render tree node |
renderValue | (values:string[], checkedItems:TreeNode[],selectedElement: ReactNode) => ReactNode | Custom render selected items |
searchable | boolean (true) |
Whether display search input box |
searchBy | (keyword: string, label: ReactNode, item: TreeNode) => boolean | Custom search rules |
size | 'lg' | 'md' | 'sm' | 'xs' ('md') |
A picker can have different sizes |
toggleAs | ElementType ('a') |
You can use a custom element for this component |
treeHeight | number (320) |
The height of the tree |
uncheckableItemValues | string[] | Set the option value for the check box not to be rendered |
value | string[] | (Controlled) specifies the values of the selected tree node |
valueKey | string ('value') |
Set value key in data |
virtualized | boolean | Whether using Virtualized List |
ts:TreeNode
interface TreeNode {
/** The value of the option corresponds to the `valueKey` in the data. **/
value: string | number;
/** The content displayed by the option corresponds to the `labelKey` in the data. **/
label: React.ReactNode;
/** The data of the child option corresponds to the `childrenKey` in the data. */
children?: TreeNode[];
}
ts:Placement
type Placement =
| 'bottomStart'
| 'bottomEnd'
| 'topStart'
| 'topEnd'
| 'leftStart'
| 'leftEnd'
| 'rightStart'
| 'rightEnd'
| 'auto'
| 'autoVerticalStart'
| 'autoVerticalEnd'
| 'autoHorizontalStart'
| 'autoHorizontalEnd';
ts: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;
}