Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

LayerTree

layer-tree

Visual-editor layer panel with nested groups, drag reordering, inline rename, visibility/lock toggles, and multi-select.

Usage

Slide Layer Panel

Supports group expand/collapse, click / Cmd multi-select / Shift range select, drag reordering into groups, double-click or F2 rename, and quick visibility/lock toggles.

Selected: main-titleHovered: None
Cover Slide Frame
Aurora Backdrop
Hero Title Group
Annual Keynote Headline
Subtitle & Release Date
Flagship Product Render
Core Metrics Card
Quarterly Growth Bar Chart
Verified Vector Badge
Internal Speaker Note
Interactive HTML Embed
Opening Promo Video
tsx
const [layers, setLayers] = useState<LayerNode[]>(slideLayers);
const [selectedIds, setSelectedIds] = useState<string[]>(["main-title"]);

<LayerTree
  layers={layers}
  onLayersChange={setLayers}
  selectedIds={selectedIds}
  onSelectionChange={setSelectedIds}
/>

Extra Row Actions & Badges

Mount status badges or quick action triggers on specific layers via renderActions.

Aurora Backdrop
Hero Title Group
Annual Keynote Headline
Subtitle & Release Date
Flagship Product Render
Core Metrics Card
Quarterly Growth Bar Chart
Live
Verified Vector Badge
Internal Speaker Note
Interactive HTML Embed
Opening Promo Video
tsx
<LayerTree
  layers={layers}
  onLayersChange={setLayers}
  renderActions={(node) =>
    node.type === "chart" ? <span className="text-[10px] text-primary">Live</span> : null
  }
/>

When to Use

Use LayerTree for the left-side layer panel in a design canvas, slide deck editor, or visual page builder alongside DesignCanvas and InspectorPanel. It handles nested layer groups, multi-selection, hover highlight synchronization, drag-and-drop nesting, and visibility/lock toggles.

  • For repository directories with Git status badges, use FileTree.
  • For general hierarchical data trees or checkable trees, use Tree.
  • For flat sortable lists, use Sortable.

Import

ts
import {
  LayerTree,
  flattenVisibleLayers,
  moveLayerNode,
  updateLayerNode,
  collectLayerIds,
  collectExpandableIds,
} from "@hulianui/ui"

Props

NameTypeDefaultDescription
layers*LayerNode[]—Layer tree data
selectedIdsstring[]—Controlled list of selected layer IDs
defaultSelectedIdsstring[][]Initial selected layer IDs in uncontrolled mode
hoveredIdstring | null—Controlled hovered layer ID for bidirectional canvas highlight sync
expandedIdsstring[]—Controlled list of expanded group IDs
defaultExpandedIdsstring[]All group IDsInitial expanded group IDs in uncontrolled mode (expands all group and frame nodes by default)
draggablebooleantrueEnables drag-and-drop reordering and nesting
renameablebooleantrueEnables inline renaming via double-click or F2 / Enter
readOnlybooleanfalseDisables drag, rename, visibility, and lock mutations while keeping selection and expand/collapse active
emptyTextstring"No layers" (zh-CN default in runtime)Placeholder text shown when layers is empty
labelsPartial<LayerTreeLabels>Built-in zh-CN labelsOverrides accessible and action button labels (tree, expand, collapse, show, hide, lock, unlock, rename)
classNamestring—Additional class name for the root tree container

Events

EventTypeDescription
onLayersChange(layers: LayerNode[]) => voidEmits the full updated immutable tree after drag-reorder, rename, visibility, or lock changes
onSelectionChange(ids: string[]) => voidEmits updated selection IDs on single click, Ctrl/Cmd toggle, or Shift visible-row range select
onHoverChange(id: string | null) => voidEmits the hovered layer ID on pointer enter and null on pointer leave
onExpandedChange(ids: string[]) => voidEmits updated expanded group IDs on expand/collapse
onRename(id: string, name: string) => voidCalled when an inline rename is confirmed (also triggers onLayersChange if provided)
onToggleVisible(id: string, visible: boolean) => voidCalled when visibility is toggled (also triggers onLayersChange if provided)
onToggleLocked(id: string, locked: boolean) => voidCalled when lock state is toggled (also triggers onLayersChange if provided)
onMove(info: LayerTreeMoveInfo) => voidCalled after a drag-and-drop move with { dragId, targetId, position, layers }

Slots

SlotTypeDescription
renderIcon(node: LayerNode) => ReactNodeCustom icon renderer overriding built-in layer type icons and node.icon
renderActions(node: LayerNode) => ReactNodeOptional extra row actions rendered to the left of the lock and visibility toggles

Data Structures

LayerNode (aliased as LayerTreeItem)

NameTypeDefaultDescription
id*string—Unique layer identifier
name*string—Display name of the layer
type"group" | "text" | "image" | "shape" | "chart" | "html" | "vector" | "media" | "frame""shape"Layer kind controlling the built-in icon and container nesting behavior
visiblebooleantrueVisibility flag; descendants inherit hidden state when an ancestor is hidden
lockedbooleanfalseLock flag; descendants inherit locked state when an ancestor is locked
childrenLayerNode[]—Child layers for container nodes such as group or frame
iconReactNode—Optional per-node custom icon override

FlattenedLayerNode (returned by flattenVisibleLayers)

NameTypeDefaultDescription
node*LayerNode—Reference to the original layer node
depth*number—Nesting depth (0 for root layers)
parentId*string | null—Parent node ID (null for root layers)
hasChildren*boolean—Whether the node has one or more child layers
effectiveVisible*boolean—Computed visibility inheriting ancestor hidden state
effectiveLocked*boolean—Computed lock state inheriting ancestor locked state

LayerTreeMoveInfo (passed to onMove)

NameTypeDefaultDescription
dragId*string—Dragged layer ID
targetId*string—Drop target layer ID
position*"before" | "inside" | "after"—Drop placement relative to the target
layers*LayerNode[]—Resulting immutable layer tree after the move

Pitfalls

  • Handling updates without onLayersChange: LayerTree does not keep an internal copy of layers. If you only pass onToggleVisible, onToggleLocked, or onRename, update your external layers state in those callbacks. When onLayersChange is provided, the component emits both the updated immutable tree and the specific callback.
  • Nesting drops: Only nodes with type of "group" or "frame", or nodes that already have a children array, accept "inside" drops. Dropping a group into itself or any of its descendants is automatically blocked.

Related

DesignCanvas · InspectorPanel · FileTree · Tree

Playground

Cover Slide Frame
Aurora Backdrop
Hero Title Group
Annual Keynote Headline
Subtitle & Release Date
Flagship Product Render
Core Metrics Card
Quarterly Growth Bar Chart
Verified Vector Badge
Internal Speaker Note
Interactive HTML Embed
Opening Promo Video
<LayerTree layers={layers} onLayersChange={setLayers} />
PreviousDesignCanvasData DisplayNextStageDraw

On this page

  • Usage
  • Documentation
    • When to Use
    • Import
    • Props
    • Events
    • Slots
    • Data Structures
    • Pitfalls
    • Related
  • Playground