Skip to content
Browse components

LayerTree

A layers panel you can select, collapse, search and add to. New layers arrive at the bottom.

Layers

Installation

Run this in a project that has a components.json. It adds one file, components/tenor-ui/layer-tree.tsx, and no packages.

pnpm dlx shadcn@latest add https://tenor.design/r/layer-tree.json

No components.json? Fetch the file. It works in any React project.

curl --create-dirs -o src/components/tenor-ui/layer-tree.tsx https://tenor.design/r/layer-tree.tsx

Usage

Every prop is optional. With none, it renders the content you see above.

<LayerTree />
import { LayerTree, type LayerTreeArrival, type LayerTreeLayer } from "@/components/tenor-ui/layer-tree"; const layers: readonly LayerTreeLayer[] = [ { id: "onboarding", name: "Onboarding – welcome", kind: "phone", children: [ { id: "top-bar", name: "Top bar", kind: "component", dot: true }, { id: "intro", name: "Intro stack", kind: "layers", children: [ { id: "intro-title", name: "Welcome title", kind: "text" }, { id: "intro-body", name: "Welcome body", kind: "text" }, ], }, ], }, ]; const stream: readonly LayerTreeArrival[] = [ { depth: 1, name: "Continue button", kind: "component" }, { depth: 0, name: "Onboarding – permissions", kind: "phone" }, { depth: 1, name: "Permission list", kind: "layers" }, { depth: 2, name: "Notifications row", kind: "frame" }, ]; export function LayersPanel() { return <LayerTree layers={layers} stream={stream} defaultSelectedId="intro" onSelect={(id) => console.log("Selected", id)} />; }

Props

PropTypeDefaultWhat it does
theme"dark" | "light""dark"Dark or light palette.
accentstring"#e65ce6"Colour of the selected layer.
layersreadonly LayerTreeLayer[]layerTreeLayersThe tree to start from. Arriving and added layers are kept inside the panel; a new array replaces them.
streamreadonly LayerTreeArrival[]layerTreeStreamLayers that arrive one at a time, repeating from the top. Defaults to none when layers is given.
intervalnumber1400Milliseconds between arrivals. 0 stops them.
selectedIdstringNoneId of the selected layer when it is controlled. Pair with onSelect.
defaultSelectedIdstringNoneId of the layer selected at first when it is not controlled. Left out, the first layer.
onSelect(id: string) => voidNoneCalled with a layer's id when it is picked, arrives or is added.
labelsPartial<LayerTreeLabels>layerTreeLabelsReplaces the panel's wording, key by key.

It also takes every attribute of its root element, such as className and style.

Theming

Set any of these CSS variables on the component or on an ancestor. Each falls back to the look shown here.

  • --tui-surface
  • --tui-stroke
  • --tui-text
  • --tui-muted
  • --tui-accent
  • --tui-on-accent
  • --tui-title
  • --tui-dim
  • --tui-pill
  • --tui-hover
  • --tui-guide
  • --tui-layer-frame
  • --tui-layer-group
  • --tui-layer-component
  • --tui-font-sans