LayoutProvider
The root context provider that owns the layout store and tab registry.
LayoutProvider is the top-level wrapper for every layout. It creates an isolated Zustand store and makes the tab registry available to all descendants. Multiple providers can coexist on the same page without interfering with each other.
Props
initialLayout (required)
The initial shape of the layout tree. Build it with createPanel and createSplit:
initialLayout is read once on mount. Changes to this prop after mount are ignored — the store owns layout state from that point on. To reset the layout externally, either remount with a new key prop or dispatch REPLACE_LAYOUT.
registry (required)
Maps tabType strings to render functions and metadata. See TabRegistry for the full shape.
onChange
Called after every successful state mutation with the new layout tree and the action that caused it. Use this to persist the layout:
The callback receives the full serializable layout tree — save it anywhere (localStorage, a database, URL params) and pass it back as initialLayout on the next mount.
generateId
Custom id generator for new nodes created at runtime (splits, tabs). Defaults to a short random string. Override this for SSR determinism or cross-instance uniqueness:
Multiple providers
Each LayoutProvider instance is fully isolated — its own store, its own registry, its own id namespace. DOM ids are auto-prefixed per provider using React's useId() so aria-controls / aria-labelledby associations never collide across instances.
Replacing the layout externally
If you need to swap the entire layout tree at runtime (e.g., switching between saved workspaces), dispatch REPLACE_LAYOUT: