Layer Tree

A canvas's layers by stacking order: type icons, hide and lock, rename, and drag to reorder or nest.

Home — light
Habit card
Habit card
Habit card
Today

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/layer-tree

Usage

import { LayerTree } from "./ui/uicontext/components/canvas/LayerTree.ts"import { CanvasChange, type Shape } from "./ui/uicontext/components/canvas/Scene.ts"
const Message = UiSchema.TaggedEnum({ RequestedSelect: { ids: Schema.Array(Schema.String) }, RequestedChange: { changes: Schema.Array(CanvasChange) } })export const Layers = (h: Html.H<typeof Message.Type>, shapes: ReadonlyArray<Shape>, selection: ReadonlyArray<string>) =>	LayerTree(h, {		props: { label: "Layers", shapes, selection },		onEmit: { RequestedSelect: ({ ids }) => Message.RequestedSelect({ ids }), RequestedChange: ({ changes }) => Message.RequestedChange({ changes }) },	})

API reference

Props

LayerTree props
NameTypeDescription
labelrequiredstring—
shapesrequiredShape[]—
selectionrequiredstring[]—
readOnlybooleanLayers can't be renamed, moved, hidden or locked
agentIdstring—

Events

LayerTree events
EventPayloadDescription
RequestedSelect{ ids: string[] }—
RequestedChange{ changes: CanvasChangeSchema[] }—

Agent actions

What agents can do with LayerTree
ActionDescription
PickedLayersSelect layers by id
RenamedLayerRename a layer by id

Source