@@ -28,10 +28,9 @@ npm install react-checkbox-tree --save
2828
2929### Include CSS
3030
31- For your convenience, the library's styles can be consumed utilizing one of the following files:
31+ The library's styles are available through one of the following files:
3232
3333* ` node_modules/react-checkbox-tree/lib/react-checkbox-tree.css `
34- * ` node_modules/react-checkbox-tree/src/less/react-checkbox-tree.less `
3534* ` node_modules/react-checkbox-tree/src/scss/react-checkbox-tree.scss `
3635
3736Either include one of these files in your stylesheets or utilize a CSS loader:
@@ -47,6 +46,7 @@ Below is a minimal example using [state hooks][docs-state-hooks]. Note that `Che
4746``` jsx
4847import React , { useState } from ' react' ;
4948import CheckboxTree from ' react-checkbox-tree' ;
49+ import ' react-checkbox-tree/lib/react-checkbox-tree.css' ;
5050
5151const nodes = [{
5252 value: ' mars' ,
@@ -149,32 +149,34 @@ Returns:
149149
150150### Properties
151151
152- | Property | Type | Description | Default |
153- | -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- | ----------- |
154- | ` nodes ` | array | ** Required** . Specifies the tree nodes and their children. | |
155- | ` checkModel ` | string | Specifies which checked nodes should be stored in the ` checked ` array. Accepts ` 'leaf' ` or ` 'all' ` . | ` 'leaf' ` |
156- | ` checked ` | array | An array of checked node values. | ` [] ` |
157- | ` direction ` | string | A string that specify whether the direction of the component is left-to-right (` 'ltr' ` ) or right-to-left (` 'rtl' ` ). | ` 'ltr' ` |
158- | ` disabled ` | bool | If true, the component will be disabled and nodes cannot be checked. | ` false ` |
159- | ` expandDisabled ` | bool | If true, the ability to expand nodes will be disabled. | ` false ` |
160- | ` expandOnClick ` | bool | If true, nodes will be expanded by clicking on labels. Requires a non-empty ` onClick ` function. | ` false ` |
161- | ` expanded ` | array | An array of expanded node values. | ` [] ` |
162- | ` icons ` | object | An object containing the mappings for the various icons and their components. See ** Changing the Default Icons** . | ` { ... } ` |
163- | ` iconsClass ` | string | A string that specifies which icons class to utilize. Currently, ` 'fa4' ` and ` 'fa5' ` are supported. | ` 'fa5' ` |
164- | ` id ` | string | A string to be used for the HTML ID of the rendered tree and its nodes. | ` null ` |
165- | ` lang ` | object | An object containing the language mappings for the various text elements. | ` { ... } ` |
166- | ` name ` | string | Optional name for the hidden ` <input> ` element. | ` undefined ` |
167- | ` nameAsArray ` | bool | If true, the hidden ` <input> ` will encode its values as an array rather than a joined string. | ` false ` |
168- | ` nativeCheckboxes ` | bool | If true, native browser checkboxes will be used instead of pseudo-checkbox icons. | ` false ` |
169- | ` noCascade ` | bool | If true, toggling a parent node will ** not** cascade its check state to its children. | ` false ` |
170- | ` onlyLeafCheckboxes ` | bool | If true, checkboxes will only be shown for leaf nodes. | ` false ` |
171- | ` optimisticToggle ` | bool | If true, toggling a partially-checked node will select all children. If false, it will deselect. | ` true ` |
172- | ` showExpandAll ` | bool | If true, buttons for expanding and collapsing all parent nodes will appear in the tree. | ` false ` |
173- | ` showNodeIcon ` | bool | If true, each node will show a parent or leaf icon. | ` true ` |
174- | ` showNodeTitle ` | bool | If true, the ` label ` of each node will become the ` title ` of the resulting DOM node. Overridden by ` node.title ` . | ` false ` |
175- | ` onCheck ` | function | onCheck handler: ` function(checked, targetNode) {} ` | ` () => {} ` |
176- | ` onClick ` | function | onClick handler: ` function(targetNode) {} ` . If set, ` onClick ` will be called when a node's label has been clicked. | ` () => {} ` |
177- | ` onExpand ` | function | onExpand handler: ` function(expanded, targetNode) {} ` | ` () => {} ` |
152+ | Property | Type | Description | Default |
153+ | -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------- |
154+ | ` nodes ` | array | ** Required** . Specifies the tree nodes and their children. | |
155+ | ` checkKeys ` | array | A list of [ keyboard keys] [ mdn-key ] that will trigger a toggle of the check status of a node. | ` [' ', 'Enter'] ` |
156+ | ` checkModel ` | string | Specifies which checked nodes should be stored in the ` checked ` array. Accepts ` 'leaf' ` or ` 'all' ` . | ` 'leaf' ` |
157+ | ` checked ` | array | An array of checked node values. | ` [] ` |
158+ | ` direction ` | string | A string that specify whether the direction of the component is left-to-right (` 'ltr' ` ) or right-to-left (` 'rtl' ` ). | ` 'ltr' ` |
159+ | ` disabled ` | bool | If true, the component will be disabled and nodes cannot be checked. | ` false ` |
160+ | ` expandDisabled ` | bool | If true, the ability to expand nodes will be disabled. | ` false ` |
161+ | ` expandOnClick ` | bool | If true, nodes will be expanded by clicking on labels. Requires a non-empty ` onClick ` function. | ` false ` |
162+ | ` expanded ` | array | An array of expanded node values. | ` [] ` |
163+ | ` icons ` | object | An object containing the mappings for the various icons and their components. See ** Changing the Default Icons** . | ` { ... } ` |
164+ | ` iconsClass ` | string | A string that specifies which icons class to utilize. Currently, ` 'fa4' ` and ` 'fa5' ` are supported. | ` 'fa5' ` |
165+ | ` id ` | string | A string to be used for the HTML ID of the rendered tree and its nodes. | ` null ` |
166+ | ` lang ` | object | A key-value pairing of localized text. See [ ` src/js/lang/default.js ` ] [ lang-file ] for a list of keys. | ` { ... } ` |
167+ | ` name ` | string | Optional name for the hidden ` <input> ` element. | ` undefined ` |
168+ | ` nameAsArray ` | bool | If true, the hidden ` <input> ` will encode its values as an array rather than a joined string. | ` false ` |
169+ | ` nativeCheckboxes ` | bool | If true, native browser checkboxes will be used instead of pseudo-checkbox icons. | ` false ` |
170+ | ` noCascade ` | bool | If true, toggling a parent node will ** not** cascade its check state to its children. | ` false ` |
171+ | ` onlyLeafCheckboxes ` | bool | If true, checkboxes will only be shown for leaf nodes. | ` false ` |
172+ | ` optimisticToggle ` | bool | If true, toggling a partially-checked node will select all children. If false, it will deselect. | ` true ` |
173+ | ` showExpandAll ` | bool | If true, buttons for expanding and collapsing all parent nodes will appear in the tree. | ` false ` |
174+ | ` showNodeIcon ` | bool | If true, each node will show a parent or leaf icon. | ` true ` |
175+ | ` showNodeTitle ` | bool | If true, the ` label ` of each node will become the ` title ` of the resulting DOM node. Overridden by ` node.title ` . | ` false ` |
176+ | ` onCheck ` | function | onCheck handler: ` function(checked, targetNode) {} ` | ` () => {} ` |
177+ | ` onClick ` | function | onClick handler: ` function(targetNode) {} ` . If set, ` onClick ` will be called when a node's label has been clicked. | ` null ` |
178+ | ` onContextMenu ` | function | onContextMenu handler: ` function(event, targetNode) {} ` . Triggers when right-clicking a node element. | ` null ` |
179+ | ` onExpand ` | function | onExpand handler: ` function(expanded, targetNode) {} ` | ` () => {} ` |
178180
179181#### ` onCheck ` and ` onExpand `
180182
@@ -196,4 +198,6 @@ Individual nodes within the `nodes` property can have the following structure:
196198[ docs-controlled ] : https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components
197199[ docs-state-hooks ] : https://react.dev/reference/react/useState
198200[ font-awesome ] : https://fontawesome.com
201+ [ lang-file ] : https://github.com/jakezatecky/react-dual-listbox/blob/master/src/js/lang/default.js
202+ [ mdn-key ] : https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
199203[ react-fontawesome ] : https://github.com/FortAwesome/react-fontawesome
0 commit comments