Zephora UI

Data

Tree

Tree view with expand/collapse, single or multiple selection, cascading checkboxes and full WAI-ARIA keyboard navigation over visible nodes.

Import

import { Tree } from "@zephora/react";

Examples

Basic selection

  • src
    • index.ts
  • package.json

Cascading checkboxes

With `checkable`, Enter/Space toggles the check instead of selecting. Checking a parent cascades to the whole subtree.

  • src
    • components
      • Button.tsx
      • Input.tsx
    • index.ts
  • package.json
Checked: 0

Multiple selection

`multiple` toggles nodes in and out of the selection on activate.

  • src
    • components
      • Button.tsx
      • Input.tsx
    • index.ts
  • package.json

API

Tree props

PropTypeDefaultDescription
data *TreeNode[]Nodes: `{ key, label, children?, disabled?, icon? }`, nested via `children`.
expandedKeys / defaultExpandedKeys / onExpandedChangestring[] / string[] / (keys: string[]) => voidControlled and uncontrolled expanded node keys.
selectedKeys / defaultSelectedKeys / onSelectedChangestring[] / string[] / (keys: string[]) => voidControlled and uncontrolled selected node keys.
multiplebooleanfalseAllow multiple selection (toggle on activate).
checkablebooleanfalseShow checkboxes; Enter/Space toggles the check instead of selecting.
checkedKeys / defaultCheckedKeys / onCheckedChangestring[] / string[] / (keys: string[]) => voidChecked node keys. Checking a parent cascades down its subtree.
unstyledbooleanfalseHeadless mode — skips Zephora styling.

Keyboard

KeyAction
ArrowDown / ArrowUpMove focus to the next / previous visible node.
ArrowRightExpands a collapsed branch; on an expanded branch moves into the first child.
ArrowLeftCollapses an expanded branch; otherwise moves focus to the parent node.
Home / EndMove focus to the first / last visible node.
Enter / SpaceSelects the node — or toggles its checkbox when `checkable` is set.