react-checkbox-tree is a React component designed to render a hierarchical tree of checkboxes. It provides a simple and elegant solution for implementing multi-select functionality with nested options. Currently stable at version 2.0.1, released in April 2026, the library recently underwent a major accessibility-focused overhaul in its 2.0.0 release. While its release cadence has historically varied, with a significant gap before the v2.x releases, the recent activity suggests ongoing development. Key differentiators include its controlled component architecture, support for customizable icons (including Font Awesome v4, v5, and v6), robust accessibility features, and strict enforcement of unique node values to optimize performance for internal state management.
npm install react-checkbox-treeVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate `react-checkbox-tree` into a React application, managing its controlled `checked` and `expanded` states using React hooks. It also shows the necessary CSS import and basic node definition.
Review any custom styling or accessibility integrations that might rely on the previous ARIA roles or structure. If using the `lang` prop, update your configuration as the `toggle` key has been replaced by `collapseNode`.
Ensure that a unique `id` string is explicitly passed to the `CheckboxTree` component's `id` prop if you require a specific or stable DOM ID. If no `id` is provided, the component will not generate one.
Include Font Awesome CSS in your project (e.g., via CDN, npm package, or build system). Alternatively, provide custom icon components via the `icons` prop to override the defaults entirely.
Always pass state variables (e.g., from `useState`) to the `checked` and `expanded` props, and ensure that their corresponding `onCheck` and `onExpand` event handlers are correctly updating those state variables.
Carefully review your `nodes` data structure and ensure that every node object, regardless of its position in the hierarchy, possesses a unique string `value`.
Add `import 'react-checkbox-tree/lib/react-checkbox-tree.css';` to your application's entry file (e.g., `index.js`/`index.tsx`) or the React component where `CheckboxTree` is being rendered.
Inspect your `nodes` array for any duplicate `value` strings. Each node's `value` must be unique across the entire tree structure.
Ensure you are using `import CheckboxTree from 'react-checkbox-tree';`. If explicitly using CommonJS, `const CheckboxTree = require('react-checkbox-tree').default;` may be necessary.Verify that your `onCheck` and `onExpand` callback functions are correctly updating the state variables (e.g., using `setChecked` and `setExpanded` from `useState`) that are then passed back into the `checked` and `expanded` props.