usePanel
Scoped hook for reading and mutating a single panel.
usePanel is the primary hook for interacting with a panel. It returns the panel's current state and a set of actions scoped to that panel. The component re-renders only when this panel's slice of the layout tree changes — not on unrelated mutations elsewhere.
Signature
panel
The current panel node from the layout tree, or null if the panel has been removed. Always check for null before reading panel fields.
setActiveTab
Activates a tab by id. Does nothing if the tab is already active.
addTab
Adds a new tab to the panel.
| Option | Default | Description |
|---|---|---|
activate | false | Switch to the new tab immediately after adding. |
index | end | Insert position in the tab list. |
removeTab
Removes a tab by id. If it was the active tab, the nearest sibling becomes active.
reorderTab
Moves a tab to a new position within the same panel. Useful for implementing drag-to-reorder within a tab bar.
split
Splits the panel in the given direction, creating a new empty panel alongside it. The new panel gets a copy of the current panel's active tab type.
toggleCollapse
Collapses or expands the panel. Pass an explicit boolean to force a specific state; omit it to toggle.
When collapsed, the panel renders at a fixed minimum height/width (36px). The resizer between it and its sibling is hidden while collapsed.
toggleMaximize
Maximizes the panel so it covers the full LayoutRoot bounds. Only one panel can be maximized at a time — maximizing a second panel un-maximizes the first. Pass an explicit boolean to force a state; omit to toggle.
closePanel
Removes the entire panel from the layout tree. If the panel is the only child of its parent split, the split is also removed. No-op if this panel is the root node.
Usage in renderPanel
usePanel is most commonly called inside the renderPanel callback: