useLayout
Access the full layout tree and dispatch actions directly.
useLayout returns the entire layout tree and a dispatch function for sending actions directly to the store. Use it for tree-wide operations or when you need to read structure that spans multiple panels.
For single-panel operations, prefer usePanel — it re-renders only when that specific panel changes.
Signature
All actions
ADD_TAB
REMOVE_TAB
SET_ACTIVE_TAB
MOVE_TAB
Moves a tab from one panel to another. The state mutation is built in — wire up your own DnD library for the visual interaction:
REORDER_TAB
SPLIT_PANEL
TOGGLE_COLLAPSE
TOGGLE_MAXIMIZE
REMOVE_PANEL
RESIZE_SPLIT
sizes must be an array of percentages that sum to 100, one per child in the split. Useful for programmatically snapping splits to specific ratios.
REPLACE_LAYOUT
Replaces the entire layout tree atomically:
Use this to switch between saved workspaces or reset the layout to a default state without remounting the provider.
Reading the tree
layout is a LayoutNode — either a PanelNode or a SplitNode. Use the exported helpers to traverse it: