@carbon/react
Version:
React components for the Carbon Design System
62 lines (61 loc) • 1.96 kB
TypeScript
/**
* Copyright IBM Corp. 2016, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { type JSX } from 'react';
import TreeNode, { TreeNodeProps } from './TreeNode';
export type TreeViewProps = {
/**
* Mark the active node in the tree, represented by its ID
*/
active?: string | number;
/**
* Specify the children of the TreeView
*/
children?: React.ReactNode;
/**
* Specify an optional className to be applied to the TreeView
*/
className?: string;
/**
* Specify whether or not the label should be hidden
*/
hideLabel?: boolean;
/**
* Provide the label text that will be read by a screen reader
*/
label: string;
/**
* **[Experimental]** Specify the selection mode of the tree.
* If `multiselect` is `false` then only one node can be selected at a time
*/
multiselect?: boolean;
/**
* **[Experimental]** Callback function that is called when any node is activated.
* *This is only supported with the `enable-treeview-controllable` feature flag!*
*/
onActivate?: (activated?: string | number) => void;
/**
* Callback function that is called when any node is selected
*/
onSelect?: (event: React.SyntheticEvent<HTMLUListElement>, payload?: Partial<TreeNodeProps> & {
activeNodeId?: string | number;
}) => void;
/**
* Array representing all selected node IDs in the tree
*/
selected?: Array<string | number>;
/**
* Specify the size of the tree from a list of available sizes.
*/
size?: 'xs' | 'sm';
} & Omit<React.HTMLAttributes<HTMLUListElement>, 'onSelect'>;
type TreeViewComponent = {
(props: TreeViewProps): JSX.Element;
propTypes?: any;
TreeNode: typeof TreeNode;
};
declare const TreeView: TreeViewComponent;
export default TreeView;