Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-tree-view.json --yes

Tree view

Pro

Nested rows a person opens and closes, to pick one (or several) of them, for React and Tailwind CSS. Part of Goop Pro.

Open a team by its chevron or the arrow keys and choose a project; Support’s projects load when it opens; the line under the tree says what is chosen and, once you open or close one, which teams are open. Turn on Tick several to tick projects and whole teams. The teams and projects are our own sample rows; Support’s rows come after a short wait of ours, nothing is fetched.

When to use

  • Nested rows a person opens and closes, to pick one (or several) of them.
  • Also called: tree or file tree.

Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Tree view on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

Terminal
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-tree-view.json --yes
PROMPT
Add the Goop Tree view to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { useState } from 'react';
import { TreeView } from '@/components/ui/goop/tree-view';

function ProjectTree() {
  const [chosen, setChosen] = useState('transcript-search');
  return (
    <TreeView
      aria-label="Projects"
      value={chosen}
      onValueChange={setChosen}
      defaultExpanded={['research']}
      items={[
        {
          id: 'research',
          label: 'Research',
          icon: 'users',
          meta: '2',
          children: [
            { id: 'transcript-search', label: 'Transcript search', icon: 'box' },
            { id: 'study-templates', label: 'Study templates', icon: 'box' },
          ],
        },
        { id: 'data-retention', label: 'Data retention settings', icon: 'box' },
      ]}
    />
  );
}
  • Fits: list: collection (depth: nested).
  • Also known as: Tree, FileTree, FolderTree, NestedList, TreeList.
  • Keys: Up and Down move, Right opens a row or enters it, Left closes it or goes to its parent, Home and End, a typed letter finds a row, * opens every row beside the focused one; one tab stop. In a sidebar, set it under a SidebarGroup's label; a list of pages a person goes to is SidebarMenuButton rows, not a tree.
  • height, width, padding, corner, background, text, motion: add no class for these.

API reference

  • Each option with its sentence: tree-view--options.md
  • State: expanded (expanded / defaultExpanded / onExpandedChange); value (value / defaultValue / onValueChange); drawn by data-focus-visible
  • data-slot values (to select a part by): tree-view, tree-view-checkbox, tree-view-chevron, tree-view-icon, tree-view-indent, tree-view-item, tree-view-label, tree-view-loading, tree-view-meta, tree-view-open-icon, tree-view-toggle

TreeView: every option

TSX
import { TreeView } from '@/components/ui/goop/tree-view';

Options

  • items: readonly TreeViewItem[] — The rows, each with its own rows under it.
  • expanded?: readonly string[] — The open rows' ids, held by the caller.
  • defaultExpanded?: readonly string[] = [] — The rows open at first, when the tree holds them.
  • onExpandedChange?: (expanded: readonly string[]) => void — Called with the open rows' ids when a row opens or closes.
  • onLoadChildren?: (id: string) => void — Asked for a row's rows when a hasChildren row with no children opens; hand them back in items.
  • guides?: boolean = false — A hairline down each level, under its parent row's chevron.
  • loadingLabel?: string = 'Loading' — The loading row's words, the caller's to translate.
  • type?: 'single' | 'multiple' = 'single' — One row is chosen. Or: Rows are ticked with checkboxes, a parent mixed while only some are.
  • value?: string | string[] — The chosen row's id ('' for none), held by the caller. Or: The ticked rows' ids, held by the caller.
  • defaultValue?: string | string[] — The row chosen at first, when the tree holds it. Or: The rows ticked at first, when the tree holds them.
  • onValueChange?: ((value: string) => void) | ((value: string[]) => void) — Called with the chosen row's id when a person chooses. Or: Called with the ticked rows' ids when a person ticks or unticks one.
  • aria-label?: string — The tree's name, said by a reader ("Projects"); or name it with aria-labelledby.
  • aria-labelledby?: string — The id of the element whose words name the tree (a heading above it).
  • State: expanded (expanded / defaultExpanded / onExpandedChange); value (value / defaultValue / onValueChange); drawn by data-focus-visible

Keyboard

KeyWhat it does
TabMove into the tree onto its chosen row (else its first), then out of it
ArrowDown ArrowUpMove to the next or the previous shown row
ArrowRightOpen a shut row, or move into an open row's first row
ArrowLeftShut an open row, or move to the row's parent
Home EndMove to the first or the last shown row
Enter SpaceChoose the focused row (tick or untick it with several chosen)
*Open every row beside the focused one
a letterMove to the next row whose words start with the letters typed

Accessibility

  • The part itself answers the keys above.
  • hover: the browser's own (:hover): write nothing

Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:

StateDrawn by
focus-visiblethe attribute data-focus-visible
selectedthe attribute aria-selected
expandedthe attribute aria-expanded
openthe attribute aria-expanded
disabledthe attribute aria-disabled

Motion

  • The part sets its own motion: add no transition or animation of your own.

Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

goop.so/themes/meadow/components/tree-view.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-tree-view.json --yes

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.