API reference
Every public export of @dashfoo/react, @dashfoo/core, and @dashfoo/theme, with types and defaults.
This page lists the full public surface of the three packages. The guides cover
the concepts; this is the lookup table. All three packages are ESM-only
("type": "module" with an exports map), so your tsconfig needs
moduleResolution: "bundler", "node16", or "nodenext". Classic "node"
resolution cannot find them. @dashfoo/react ships a "use client" banner, so
it works as a client component in the Next.js App Router without a wrapper.
@dashfoo/react
The React binding: DashfooLayout, the Panel compound parts, the hooks, and
the storage adapters.
Source: packages/react/src.
DashfooLayout props
The component props. The props are a union: pass either model (controlled)
or defaultModel (uncontrolled), never both and never neither. persist
only exists on the defaultModel side. All three rules are enforced by the
type, so the combinations that used to type-check and silently do nothing no
longer compile. DashfooLayoutCommonProps is exported for helpers that spread
overrides.
| Prop | Type | Default | Description |
|---|---|---|---|
model | Dashfoo | none | Controlled document, and the only source of truth: every dispatch is applied to this prop, so a change you do not apply is simply not applied. Normalized before render. |
defaultModel | Dashfoo | none | Uncontrolled initial document. The component owns it from there. |
onModelChange | (model: Dashfoo, action?: Action) => void | none | Fires after every change with the next model and the action that caused it (action is omitted for undo/redo). Not required for persistence: persist saves on its own. |
components | Record<string, TabComponent> | none | Registry mapping tab.component keys to components. Each receives { node: TabNode }. Without factory, a key with no registered component renders nothing and warns once per key, whether or not components was passed. |
factory | (tab: TabNode) => ReactNode | none | Render override. When set it resolves every tab and components is ignored. |
persist | string | { key: string; storage?: StorageAdapter; debounceMs?: number; mapTab?: MapTab } | none | Auto-save and restore the model. Only accepted alongside defaultModel. A bare string is a localStorage key; the debounce defaults to 300 ms. See persistence. |
onAction | (action: Action) => Action | null | none | Intercept each action before it commits: return it, a replacement, or null to veto. |
onActiveTabsetChange | (tabsetId: string | undefined) => void | none | Fires when the active tabset changes. |
onMaximizedTabsetChange | (tabsetId: string | undefined) => void | none | Fires when a tabset is maximized or restored. |
renderTabLabel | (tab: TabNode) => ReactNode | none | Override the tab label. The accessible name stays tab.name. |
renderTabsetToolbar | (tabset: TabsetNode) => ReactNode | none | Inject custom controls into a tabset's toolbar. |
editable | boolean | true | The umbrella switch. false renders a static layout: no tab/tabset drag, close, rename, splitter resize, or external drops. |
restructurable | boolean | true | false freezes the tree: no tab or tabset drag, split resizing, floating or external drops. Tabs stay closable and renamable. Compact responsive mode forces it off. |
closableTabs | boolean | true | Show the per-tab close control. |
renamableTabs | boolean | true | Allow double-click inline rename. |
maximizable | boolean | true | Show the tabset maximize/restore control. |
floatable | boolean | false | Show a per-tabset control that floats the panel into a movable, resizable overlay, and render any floating panels (Dashfoo.floats). Opt-in. See floating panels. |
draggableTabs | boolean | true | Allow individual tabs to be dragged between tabsets. |
draggableTabsets | boolean | true | Let a whole tabset be dragged by its grip or the empty space in its header. |
dragGroup | string | none | Layouts with the same group exchange tabs and tabsets by drag, across popup windows and other browser tabs of the same origin. Mouse drags use the browser's drag and drop while it is set. See multiple windows. |
dragGroupScope | "origin" | "app" | "origin" | "app" keeps this layout's drags within this copy of the app: it neither sends to nor accepts from other windows' copies. |
edgeDocking | boolean | true | Let tabs and tabsets be dropped at the layout's edges, beside everything else, as a sidebar or bottom panel. Needs split docking (global.enableSplitDock). |
onTearOff | (request: TearOffRequest) => boolean | none | Called when a tab or tabset is released outside the window. Return true to remove it (a tearOff action). The drag preview carries data-tear-off while a release would tear off. |
resizableSplits | boolean | true | Allow dragging the splitters between panels. false disables them but keeps them mounted, so the gutters hold their size. |
keepMounted | boolean | "activity" | false | Keep inactive tab panels mounted (hidden) so their state survives a tab switch. By default inactive panels unmount. "activity" renders them in a hidden React <Activity> (state kept, effects paused; React 19.2+). |
responsive | { maxWidth: number; orientation?: Orientation } | none | At or below maxWidth (the layout's own container width, not the viewport) render a stacked column and lock drag + resize. A view-only projection: the model is untouched, so widening up is lossless and the layout never remounts. See responsive. |
snap | { step?: number; divisions?: number | "panels"; threshold?: number } | none | Magnetic snapping for splitter drags. The dragged boundary pulls onto a grid: the union of step (multiples of a fixed percent) and divisions (even splits: multiples of 100/d, where d is the number, or "panels" to divide by the row's panel count so a 3-panel row snaps to thirds). Within threshold percent (default 4) it snaps and commits on release as one undo step. Omitted โ off; replaces (not merges with) global.snap; a row can override via its own snap. Locked off in compact mode. |
The capability props (editable through snap, restructurable and
keepMounted included) are the exported LayoutOptions type, which
DashfooLayout and Layout.Root share. DashfooLayout passes them through and
Layout.Root resolves every default in one place. In compact responsive mode
the responsive locks override maximizable and restructurable.
The model's global block layers under the boolean props: a feature is on only
if neither the prop nor the global (tabEnableClose, tabEnableRename,
tabSetEnableMaximize, tabEnableDrag, enableSplitResize) turns it off, and
(for everything except maximize) only while editable is on. The root element
is <div data-dashfoo="layout"> at 100% of its parent in both axes. A parent
without a real height paints nothing (see getting started).
Static layouts
editable={false} freezes the arrangement in one move: tabs and tabsets cannot
be dragged, tabs cannot be closed or renamed, splitters stop resizing (they stay
mounted, so nothing reflows), and the layout rejects drops from
useExternalTabSource, even under a shared DashfooDragProvider while a
sibling layout stays editable. The dashboard remains interactive as a viewer:
tab selection, keyboard tab navigation, the overflow menu, and maximize/restore
remain available, and the imperative DashfooHandle / dispatch API still
mutates the model programmatically. Flip the prop at runtime to build an "edit
mode" toggle without a remount.
DashfooHandle
A ref on DashfooLayout exposes 20 imperative methods.
| Method | Signature | Effect |
|---|---|---|
addTab | (tab: TabNode, target: { targetId: string; location?: DockLocation; index?: number }) => void | Dispatches addNode. location defaults to "center"; index picks the slot when stacking into the target. |
closeTab | (tabId: string) => void | Dispatches deleteTab. |
selectTab | (tabsetId: string, index: number) => void | Dispatches selectTab. |
renameTab | (tabId: string, name: string) => void | Dispatches renameTab. |
maximizeTabset | (tabsetId: string | null) => void | Dispatches setMaximizedTabset; null restores. |
collapseTabset | (tabsetId: string) => void | Dispatches setTabsetCollapsed with collapsed: true. |
expandTabset | (tabsetId: string) => void | Dispatches setTabsetCollapsed with collapsed: false. |
floatTab | (tabId: string) => void | Floats a tab into a movable, resizable panel. |
floatTabset | (tabsetId: string) => void | Floats a whole tabset into a movable, resizable panel. |
dockFloat | (floatId: string) => void | Docks a floating panel back into the main layout. |
setFloatMinimized | (floatId: string, minimized: boolean) => void | Collapses a float to its chip, or restores it. |
dispatch | (action: Action) => void | Raw escape hatch for any of the 22 actions. |
getModel | () => Dashfoo | The current model. |
getTablistSpace | (tabsetId: string) => number | undefined | Free space in a tabset's tablist, in layout pixels; negative once its tabs overflow. |
onTablistSpaceChange | (tabsetId: string, listener: (space: number) => void) => () => void | Calls listener before paint whenever that space changes. Returns the unsubscribe. |
undo | () => void | Step back one action. No-op in controlled mode. |
redo | () => void | Step forward. No-op in controlled mode. |
canUndo | () => boolean | Reads the live history snapshot. |
canRedo | () => boolean | Reads the live history snapshot. |
resetLayout | () => void | Restore the original defaultModel, clearing undo history and any persisted copy. Unavailable in controlled mode (warns once). |
import type { TabNode } from "@dashfoo/core";
import { model, row, tab, tabset } from "@dashfoo/core";
import type { DashfooHandle } from "@dashfoo/react";
import { DashfooLayout } from "@dashfoo/react";
import type { ReactNode } from "react";
import { useRef } from "react";
const Notes = ({ node }: { node: TabNode }): ReactNode => <div>{node.name}</div>;
const initial = model(row([tabset([tab("notes", "Notes")], { id: "main" })]));
const App = (): ReactNode => {
const ref = useRef<DashfooHandle>(null);
const handleAdd = (): void => {
// ids default to the component name; pass an explicit id for a duplicate.
ref.current?.addTab(tab("notes", "Scratch", { id: "notes-2" }), {
location: "split-right",
targetId: "main",
});
};
return (
<div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
<button onClick={handleAdd} type="button">
Add tab
</button>
<div style={{ flex: 1, minHeight: 0 }}>
<DashfooLayout components={{ notes: Notes }} defaultModel={initial} ref={ref} />
</div>
</div>
);
};
export { App };See controlled & history for the controlled-mode pairing and undo/redo wiring.
Panel compound parts
Unstyled building blocks for panel content. Each forwards its native props and
adds a data-dashfoo attribute for styling.
| Part | Element | Attribute |
|---|---|---|
Panel.Root | <div> | data-dashfoo="panel" |
Panel.Header | <div> | data-dashfoo="panel-header" |
Panel.Body | <div> | data-dashfoo="panel-body" |
Panel.Title | <span> | data-dashfoo="panel-title" |
Panel.Icon | <span> | data-dashfoo="panel-icon" |
Panel.Badge | <span> | data-dashfoo="panel-badge" |
Prop types are exported as PanelRootProps, PanelHeaderProps,
PanelBodyProps, PanelTitleProps, PanelIconProps, and PanelBadgeProps.
Layout and Tabset compound parts
The primitives DashfooLayout itself is built from, exported for hand-built
layouts. Layout.Root (the frame, layout store and drag root), Layout.DragLayer
(drag-dock, optional), Layout.Rows (the split tree, with a renderTabset
render prop; while a tabset in its tree is maximized it renders only that
tabset, through renderTabset too), Layout.Tabset (the stock tabset composition), and, for
floating panels, Layout.FloatLayer (wrap the tree's content,
passing floats, to render each floated panel as a draggable overlay).
Layout.Root takes model, dispatch, renderers, an optional rootRef, an
optional tablistSpace (from createTablistSpace(), to read each tabset's
tablist space from outside the layout), and LayoutOptions, the same capability
props as DashfooLayout.
Plus the full tabset decomposition under Tabset.*: Root, TabStrip, Tablist,
Tab, Trigger, RenameInput, CloseButton, Content, Toolbar, OverflowMenu,
Grip, CollapseButton, MaximizeButton, and FloatButton. Each part spreads native props and is
unstyled beyond minimal structural flex. On CloseButton, Grip, CollapseButton
and MaximizeButton, children, className, style and title may also be
functions of the part's state: { tab, isSelected }, { isDragging },
{ isCollapsed } and { isMaximized } respectively, e.g.
{({ isCollapsed }) => (isCollapsed ? "โธ" : "โพ")}. See
Build your own layout for the part table and a
complete example.
useDashfooStore
The store DashfooLayout uses internally, exposed for hosts that render their
own chrome. It owns the whole document lifecycle: the controlled/uncontrolled
choice, undo/redo history, and persistence. Throws when given neither model
nor defaultModel; every entry point is normalized.
UseDashfooStoreOptions:
| Option | Type | Description |
|---|---|---|
defaultModel | Dashfoo | Uncontrolled seed; the store owns it with full undo/redo. |
model | Dashfoo | Controlled document; every change routes through onModelChange. |
onAction | (action: Action) => Action | null | Veto or replace an action before it commits. |
onActiveTabsetChange | (tabsetId: string | undefined) => void | Active-tabset notifications. |
onMaximizedTabsetChange | (tabsetId: string | undefined) => void | Maximize/restore notifications. |
onModelChange | (model: Dashfoo, action?: Action) => void | Fires once per real change (no-op transitions emit nothing). |
persist | PersistInput | Uncontrolled only. Loads once after mount, restores without an undo entry, a save or onModelChange, and debounce-saves every change. See below. |
Returns a DashfooStore:
| Field | Type | Description |
|---|---|---|
model | Dashfoo | The current document. |
dispatch | (action: Action) => void | Commit one action. |
undo | () => void | Uncontrolled only. |
redo | () => void | Uncontrolled only. |
canUndo | () => boolean | Reads the live history, not a stale render value. |
canRedo | () => boolean | Reads the live history. |
setModel | (model: Dashfoo) => void | Replace the whole document and reset undo history. Saved when persist is set. |
reset | () => void | Clear the saved copy and restore defaultModel without an undo entry. Uncontrolled only. |
useLayout
Selector hook over the layout store: the layout's resolved configuration and
dispatch, for custom chrome (a renderTabsetToolbar button, a custom tab
label). useLayout((state) => state.dispatch) re-renders only when the
selected slice changes. Throws outside <DashfooLayout> / <Layout.Root>.
The LayoutState fields:
| Field | Type | Description |
|---|---|---|
documentId | string | Stable Layout.Root identity shared by its main and float layers. |
canDock | boolean | Current docking permission, resolved as editable && restructurable. Checked at intent resolution and commit. |
dispatch | (action: Action) => void | The store's dispatch. |
closableTabs, renamableTabs, maximizable, draggableTabs, draggableTabsets, resizableSplits | boolean | Effective values after editable and the model globals are layered in (maximizable ignores editable). |
editable | boolean | The umbrella prop as passed; gates every structural capability above except maximizable. |
keepMounted | boolean | "activity" | The resolved prop. |
dragGroup, dragGroupScope | string | undefined, "origin" | "app" | The resolved drag group (unset while docking is off) and its scope. |
onTearOff | TearOffHandler | undefined | The resolved prop. |
maximizedTabsetId | string | undefined | The currently maximized tabset, if any. Must live in the main layout: normalize clears it once that tabset moves into a float. |
renderTab | (tab: TabNode) => ReactNode | The resolved content renderer (factory or registry). |
renderTabLabel, renderTabsetToolbar | optional render props | As passed to DashfooLayout / Layout.Root. |
splitDock | boolean | From global.enableSplitDock. |
tabLocation | "top" | "bottom" | From global.tabLocation, default "top". |
tabsetMinSize | number | From global.tabSetMinSize, default 320 here. |
tabStripEnabled | boolean | From global.tabSetEnableTabStrip. |
useTabset / useTab / useDragSubject / useDropIntent / useDropIndicator
useTabset((state) => โฆ) selects from the per-tabset store inside
<Tabset.Root>: documentId, node, visualSelected, activeTab, isMaximized,
editingTabId, overflowItems, tablistSpace (free layout pixels in the tablist, negative once the tabs overflow, undefined until measured), the resolved flags (tabsClosable,
tabsRenamable, showMaximize), and the actions (selectTab, closeTab,
renameTab, startEditing, stopEditing, toggleMaximize,
selectOverflowTab). A custom rename editor calls renameTab(tabId, name),
then stopEditing(); Tabset.RenameInput does both, and skips an empty or
unchanged name.
useTab() returns { closable, draggable, index, renamable, tab } inside
<Tabset.Tab>: which tab the part belongs to, and whether it can be closed,
dragged and renamed. The flags combine the layout, the tabset and the tab's own
enableClose / enableDrag / enableRename. Custom parts should read them
rather than the tabset's tabsClosable / tabsRenamable, which are only the
layout and tabset half.
useDragSubject() returns the live drag subject or null, including outside any
layout or provider. Internal subjects carry { kind: "tab" | "tabset", id, documentId }; external subjects carry { kind: "external", id, tab }. Match
documentId against useLayout((state) => state.documentId) when styling local
nodes under a shared provider. See
Build your own layout.
useDropIntent() returns the live drop intent ({ targetId, location, index? },
where the drag would land if dropped right now) or null when nothing is
dragging or the pointer is over no valid target (empty space, a non-editable
layout, a structurally locked layout, a foreign internal drag, or a suppressed no-op drop). Both hooks work anywhere under a layout;
under a DashfooDragProvider they work anywhere under the provider. Pair with
dockZonePolygons, resolveDropIntent and dropIndicator from @dashfoo/core
for custom drop indicators and drop-zone visualizations.
useDropIndicator(): DropIndicator | null returns what the built-in dock
indicator draws ({ kind: "edge" | "insertion" | "zone"; rect } in viewport
pixels), taken from the same measurement as the intent.
measureTabset
measureTabset(id: string, element: HTMLElement): MeasuredTabset is the DOM
read behind the library's drop intent and dock indicator: the tabset's rect and
writing direction, plus its own strip's rect and tab items when it has a strip
(strips of a layout nested in its content are skipped). Pass the result to resolveDropIntent or
dropIndicator to build a zone map that matches the library. Tabset roots
render data-tabset-id="<node id>". To draw only the current target, read
useDropIndicator() instead.
Persistence
persist on DashfooLayout and on useDashfooStore takes a PersistInput:
string | { key: string; storage?: StorageAdapter; debounceMs?: number }. A bare
string is a localStorage key; the debounce defaults to 300 ms. The saved model is
validated on load (corrupt values are pruned with a warning), and a pending save
flushes on page hide (pagehide / visibilitychange โ hidden) and on unmount.
See persistence.
Storage adapters
| Export | Type | Description |
|---|---|---|
StorageAdapter | { getItem: (key: string) => string | null; setItem: (key: string, value: string) => void; removeItem: (key: string) => void } | The minimal localStorage-shaped contract. |
localStorageAdapter | StorageAdapter | window.localStorage, unwrapped. It throws like localStorage; the persistence loop catches and warns. |
memoryStorageAdapter() | () => StorageAdapter | Factory returning a fresh Map-backed adapter, for tests, SSR, and ephemeral layouts. |
External drag sources
Drag new tabs in from outside the layout. See drag & dock for the full flow.
| Export | Signature | Description |
|---|---|---|
DashfooDragProvider | ({ children }) => ReactNode | A drag root: one drag manager and drag lifecycle for layouts, their floats and outside sources. Every Layout.Root mounts one; an inner root reuses the outer. |
useExternalTabSource | (options: ExternalTabSourceOptions) => { ref } | Registers an element as a drag source; put ref on it. Warns once when no drag root is above it. |
ExternalTabSourceOptions | { createTab: () => TabNode; label?: string; disabled?: boolean } | createTab runs at drag start and must mint a fresh tab id per call. |
useResponsiveLayout
useResponsiveLayout(model: Dashfoo, options: ResponsiveOptions | undefined): ResponsiveLayout
is the compact projection behind DashfooLayout's responsive prop, exported for
hand-built layouts. It measures the element behind rootRef with a
ResizeObserver (SSR-safe: the width starts at infinity) and, at or below
maxWidth, returns a stacked view of the model that keeps every row ancestor so
mounted panels survive. undefined options never compact. See
responsive.
| Type | Shape |
|---|---|
ResponsiveOptions | { maxWidth: number; orientation?: Orientation } |
ResponsiveLayout | { isCompact: boolean; locks: Pick<LayoutOptions, "maximizable" | "restructurable">; model: Dashfoo; rootRef: (el: HTMLElement | null) => void } |
Pass model and rootRef to Layout.Root and spread locks after any
capability props you set: <Layout.Root {...responsive.locks} dispatch={โฆ} model={responsive.model} โฆ>.
locks is {} when wide and { maximizable: false, restructurable: false }
when compact, which locks tab and tabset drag, split resizing, floating and
maximize.
@dashfoo/core
The framework-free engine: schema, builders, actions, reducer, tree queries,
geometry, history, serialization, and the drag/dock XState machine.
Source: packages/core/src.
Actions
Every document mutation is one of 22 immutable, discriminated actions. The
reducer is exhaustive over the union; validate untrusted payloads with
actionSchema before dispatch.
action.type | Payload | Effect |
|---|---|---|
addNode | { tab, targetId, location, index? } | Insert a new tab at a dock location. |
moveNode | { sourceId, targetId, location, index? } | Move an existing tab to a dock target. |
moveTabset | { sourceId, targetId, location } | Move a whole tabset to a dock target (the grip drag). No index: a tabset merges or docks beside, so there is no strip slot to land at. |
selectTab | { tabsetId, index } | Set a tabset's selected index. |
setActiveTabset | { tabsetId } | Mark the focused tabset. |
setMaximizedTabset | { tabsetId: string | null } | Maximize one tabset, or restore with null. |
setTabsetCollapsed | { tabsetId, collapsed } | Collapse a collapsible tabset to its strip, or expand it. Never collapses the last expanded child of a row. |
renameTab | { tabId, name } | Change a tab's name. |
deleteTab | { tabId } | Remove a tab. |
deleteTabset | { tabsetId } | Remove a whole tabset. |
adjustSplit | { rowId, weights } | Set the weights of a row's children (the splitter drag). |
floatTab | { tabId, geometry?, floatId? } | Float a tab out into a new floating panel. |
floatTabset | { tabsetId, geometry?, floatId? } | Float a whole tabset (with its tabs) into a panel. |
dockFloat | { floatId, targetId?, location? } | Dock a float back as its own panel (or center-merge). |
moveFloat | { floatId, geometry } | Update a floating panel's stored rect (drag/resize). |
setFloatMinimized | { floatId, minimized } | Collapse a float to a chip, or restore it. |
renameFloat | { floatId, name } | Rename a float's title (deduped to stay unique). |
tearOff | { nodeId } | Remove a tab or tabset that left the window (see onTearOff). |
transferOut | { nodeId } | Remove a tab or tabset that was dropped into another layout of the drag group. |
transferIn | { node, targetId, location, index? } | Insert a tab or tabset dragged in from another layout. A tab id already in the layout rejects it with a warning; a taken tabset id is replaced. |
updateNodeAttributes | { nodeId, attrs } | Patch mutable attributes on a tab, tabset, or row. |
updateGlobalAttributes | { attrs } | Patch the model's global block. |
The seven docking actions (addNode, moveNode, moveTabset, floatTab,
floatTabset, dockFloat, transferIn) resolve their target before detaching anything, so a
drop that cannot land is a no-op, and they activate the tabset that received
the content: the target on a center drop, the placed tabset on a split, the
floated tabset when floating. addNode with an id already in the layout is
ignored with a [dashfoo] warning. dockFloat with a targetId needs a tabset
in the main layout (any other id is a no-op); without one it targets the active
main tabset, else the first, and into an empty main layout the float's layout
becomes the layout. addNode, moveNode, moveTabset and transferIn also
take the main layout's row id as targetId while that layout is empty: it seeds
a tabset there, so an emptied layout still takes drops. A moveNode that splits a one-tab tabset off its own tab is
a no-op, as is a setMaximizedTabset naming a tabset in a float. When a tab leaves a strip, the selection
stays on the selected tab; if that tab is the one leaving, it passes to the right
neighbour, else the left, or under global.tabSetSelectOnRemove: "recent" to the
tab selected before it.
Related exports: actionSchema, dockLocationSchema, mutableNodeAttrsSchema,
and the types Action, MutableNodeAttrs,
DockLocation ("center" | "split-top" | "split-bottom" | "split-left" | "split-right"),
and DropIntent ({ targetId: string; location: DockLocation; index?: number }).
See drag & dock for how drops become actions.
Builders
Constructors that fill the mechanical fields (type, version, selected,
weight, floats) so seed models stay short.
| Builder | Signature | Notes |
|---|---|---|
tab | (component: string, name: string, options?: TabOptions) => TabNode | id defaults to component. Pass an explicit id when reusing a component. |
tabset | (children: Array<TabNode>, options?: TabsetOptions) => TabsetNode | selected defaults to 0 and is clamped into the strip; weight defaults to 1; id is auto-generated when omitted. |
row | (children: RowNode["children"], options?: RowOptions) => RowNode | orientation defaults to "row"; weight defaults to 1; id is auto-generated when omitted. |
model | (layout: RowNode, options?: ModelOptions) => Dashfoo | Fills version: 1, global: {} and floats: []; warns once on duplicate node ids. |
floatNode | (layout: RowNode, geometry: Geometry, options?: FloatOptions) => FloatNode | A floating panel wrapping a layout subtree at an in-app rect. |
Option types: TabOptions (config, enableClose, enableDrag,
enableRename, id), TabsetOptions (collapsed, collapsible, enableClose, enableDrag, enableMaximize, id,
max, min, name, selected, weight), RowOptions (id, max, min,
orientation, weight), ModelOptions (activeTabsetId, floats, global,
maximizedTabsetId), FloatOptions (id, name). min/max
accept a bare number (treated as px) or a Dimension.
Schema
Zod schemas and their inferred types. Field-by-field tables live in the model guide.
| Schema | Inferred type |
|---|---|
dashfooSchema | Dashfoo |
rowNodeSchema | RowNode |
tabsetNodeSchema | TabsetNode |
tabNodeSchema | TabNode |
floatNodeSchema | FloatNode |
geometrySchema | Geometry |
globalAttributesSchema | GlobalAttributes |
dimensionSchema | Dimension |
snapSchema | SnapConfig |
orientationSchema | Orientation |
unitSchema | Unit |
jsonValueSchema | Json |
DashfooInput (z.input<typeof dashfooSchema>) is the loose counterpart of
Dashfoo: the shape parseModel accepts, with weight and floats optional.
Hold host-supplied or stored data as DashfooInput and parse it into a
Dashfoo. The schemas check shape only: a selected past the end of its strip
parses, and normalize clamps it.
Constants: DEFAULT_WEIGHT (1, the weight parseModel and the builders
fill in), DEFAULT_FLOAT_NAME ("Panel", the title of a float with no name
and the base new floats are numbered from), and DEFAULT_FLOAT_GEOMETRY
({ height: 360, left: 80, top: 80, width: 480 }, the rect a float gets when
floatTab or floatTabset omits geometry, and the size cap the React float
button applies).
Node (RowNode | TabsetNode | TabNode) is exported as a type only.
FloatNode ({ type: "float"; id; layout: RowNode; geometry: Geometry; name?; minimized? })
holds a floating panel; see floating panels. The model's
version is the pinned literal 1; payloads with any other version fail
validation.
Reducer and normalize
| Export | Signature | Description |
|---|---|---|
reducer | (model: Dashfoo, action: Action) => Dashfoo | The pure engine: deep-copies via structuredClone (input never mutated), applies one action, runs normalize, then compares the result structurally with the input. Returns the input by reference when they match, so identity equality means "no edit", including an edit normalize undoes (maximizing a float's tabset) or an identical attribute re-sent. |
normalize | (model: Dashfoo) => Dashfoo | The single owner of the model's invariants: removes empty tabsets, collapses single-child rows, heals each float's layout and drops an emptied float, clamps every tabset's selected into its strip, keeps activeTabsetId on a live tabset anywhere, and maximizedTabsetId on a live tabset in the main layout (floats opt out of maximize, so floating the maximized tabset clears it). weight defaults are settled at the parse boundary instead. |
Tree helpers
Read-only queries over a model. All of them take the whole model and span
every root, so a floated node is as reachable as a docked one. Matching is
predicate-first: an id that also names a node of another kind cannot make two
of these disagree about which node wins.
| Function | Signature | Description |
|---|---|---|
collectRoots | (model: Dashfoo) => Array<RowNode> | The main layout plus each floating panel's layout. |
collectTabsets | (model: Dashfoo) => Array<TabsetNode> | Every tabset across all roots, depth-first. |
collectTabsetsInRow | (row: RowNode) => Array<TabsetNode> | Every tabset under one row, depth-first. |
getFirstTabset | (model: Dashfoo) => TabsetNode | undefined | The first tabset in document order. |
findTabset | (model: Dashfoo, tabsetId: string) => TabsetNode | undefined | A tabset by id. |
findTab | (model: Dashfoo, tabId: string) => TabLocation | undefined | A tab anywhere in the model: { tab, container, index }. |
findFloat | (model: Dashfoo, floatId: string) => FloatNode | undefined | A floating panel by id. |
findRow | (model: Dashfoo, id: string) => RowNode | undefined | A row by id. |
findAttributedNode | (model: Dashfoo, id: string) => AttributedNode | undefined | Any row, tabset, or tab by id. Backs updateNodeAttributes. |
findTabsetParent | (model: Dashfoo, tabsetId: string) => TabsetSlot | undefined | The row holding a tabset, its index within it, and the tabset. |
findDuplicateIds | (model: Dashfoo) => Array<string> | Ids appearing more than once across the whole model. |
standaloneModel | (model: Dashfoo, nodeId: string) => Dashfoo | undefined | A model holding only that tab (in a tabset of its own) or tabset, with the source's global. What onTearOff receives. |
Types: AttributedNode, TabLocation,
TabsetSlot ({ index: number; parent: RowNode; tabset: TabsetNode }).
Ids
| Function | Signature | Description |
|---|---|---|
createNodeId | (prefix?: string) => string | `${prefix}-${uuid}`, prefix defaults to "node". |
createTabId | () => string | createNodeId("tab"). |
Geometry
| Export | Signature | Description |
|---|---|---|
resolveDockTarget | (pointer: Point, rect: Rect) => DockLocation | Center of a tabset resolves to "center" (stack); within an outer edge band (a fixed 22%) to "split-left" and friends. |
dockZonePolygons | (rect: Rect) => Array<DockZone> | The full hit-region partition behind resolveDockTarget: the inner center rect plus four edge trapezoids, as polygons. Shares the band, so a painted map always agrees with the live hit-test. |
zoneRect | (rect: Rect, location: DockLocation) => Rect | The region the dock indicator highlights: the whole rect for center, the matching half for a split-*. |
Types: Point ({ x: number; y: number }), Rect
({ x: number; y: number; width: number; height: number }), DockZone
({ location: DockLocation; points: Array<Point> }).
Drop intent
What a pointer over a tabset means, over a measured tabset instead of the DOM. The React drag layer passes one measurement to both functions, so the insertion index and the insertion line always agree. See drag & dock.
| Export | Signature | Description |
|---|---|---|
resolveDropIntent | (subject: DragSubject, tabset: MeasuredTabset, point: Point, opts?: DropIntentOptions) => DropIntent | null | null for a self-drop (a tabset onto itself, a sole tab onto its own tabset); a center stack at the insertion index over the strip; otherwise resolveDockTarget over the body. |
dropIndicator | (subject: DragSubject, tabset: MeasuredTabset, intent: DropIntent, opts?: DropIntentOptions) => DropIndicator | The edge zone for a drop at the layout's edge, the insertion line for a center drop onto a strip, otherwise the zoneRect of the intent. |
Types: DragSubject ({ kind: "tab" | "tabset"; id: string; documentId: string }
for a node in a layout, { kind: "external"; id: string; tab: TabNode } for an
outside source), DropIntent ({ targetId: string; location: DockLocation; index?: number }),
MeasuredTabset ({ direction?: "ltr" | "rtl"; id: string; rect: Rect; strip: MeasuredStrip | null }),
MeasuredStrip ({ rect: Rect; tabs: ReadonlyArray<MeasuredTab> }, tabs in
strip order), MeasuredTab ({ id: string; rect: Rect }, spanning the whole tab
item), DropIntentOptions ({ edges?: MeasuredLayout; foreign?: boolean; splitDock?: boolean }:
splitDock: false turns every body drop into a stack, edges turns on
drops at the layout's edges, and foreign: true marks a subject from another
document so a shared tabset id is not a self-drop), MeasuredLayout ({ id: string; rect: Rect; tabsetCount: number },
the main layout's root row), DropIndicator ({ kind: "edge" | "insertion" | "zone"; rect: Rect }).
History
Past/present/future snapshots over the reducer. Every dispatched action is one
undo step; there is no coalescing. A splitter drag is still a single step
because react-resizable-panels v4 commits one adjustSplit per release.
| Export | Signature | Description |
|---|---|---|
createHistory | (present: Dashfoo) => History | A fresh history over the normalized model, with empty past and future. |
dispatchToHistory | (history: History, action: Action) => History | Reduce present, push the old one to past, clear future. A no-op action returns history. |
undoHistory | (history: History) => History | Step back; returns the same history at the bottom. |
redoHistory | (history: History) => History | Step forward; returns the same history at the top. |
canUndoHistory | (history: History) => boolean | past is non-empty. |
canRedoHistory | (history: History) => boolean | future is non-empty. |
HISTORY_LIMIT | number | The most recent steps kept in past (100). |
History is { past: Array<Dashfoo>; present: Dashfoo; future: Array<Dashfoo> }.
Serialization
| Export | Signature | Description |
|---|---|---|
toJSON | (model: Dashfoo) => string | JSON.stringify, since the model is plain data. |
fromJSON | (json: string) => Dashfoo | Parse + parseModel. Throws on invalid input. |
parseModel | (value: unknown) => Dashfoo | Validate against dashfooSchema (including the pinned version: 1), normalize, and warn on duplicate node ids. Takes DashfooInput-shaped data: weight and floats may be omitted and come back filled in. |
restoreModel | (value: unknown, options?: { mapTab?: MapTab }) => Dashfoo | null | The tolerant form for saved layouts: warns and returns null for anything that is not a model. mapTab returns each saved tab's current version, or null to drop it, before the model is normalized. |
Machines
One XState machine, for hosts that bypass the React binding. The document
needs none: hold a History and step it with the functions above.
The machine lives in @dashfoo/core/internal, the entry point for what a
rendering layer builds on. It carries no semver promise, so a package that
imports it pins @dashfoo/core to an exact version. The same entry point
exports fallbackSelectedIndex ((tabset, removedIndex, policy?) => number:
the index of the tab that inherits the selection when the selected tab at
removedIndex leaves, -1 when none remains), canCollapseTabset
((parent: RowNode, tabset) => boolean: whether setTabsetCollapsed would
collapse it), the snap functions (resolveSnapGrid, decideSnap,
settleSnap, snapEnabled) and warn / warnOnce.
dragDockMachine: the drag/dock interaction lifecycle. Events:START({ subject: DragSubject }),OVER({ drop: DropResolution | null }),DROP,CANCEL. Its context is oneDragState({ kind: "idle" } | { kind: "dragging"; subject; drop }), so a drop target without a subject is unrepresentable. A valid drop emits{ type: "COMMIT", action, scope, subject }, wherescopeechoes back theDropResolution.scopethat resolved the intent so the host can route the action and recheck document ownership:moveNodefor a tab drag,moveTabsetfor a tabset-grip drag;addNodeonly for an external source.dropAction(drag)is the same decision as a plain function. Types:DragState,DropResolution({ indicator, intent, scope };DragSubjectis listed under Drop intent).
@dashfoo/theme
The opt-in default skin over --dashfoo-* tokens, light by default, dark via
data-dashfoo-theme="dark" on any ancestor. The full token table is in
theming.
| Entry point | Contents |
|---|---|
@dashfoo/theme/tailwind.css | Tailwind v4 source entry: tokens + skin in cascade layers, plus an @theme bridge that generates dashfoo-* utilities. |
@dashfoo/theme/dashfoo.css | The prebuilt skin, compiled from the same source (tokens included, flattened). One import styles everything; no Tailwind needed. |
@dashfoo/theme/tokens.css | The tokens alone, for building your own skin on the same override surface. |
The only JS export is DASHFOO_THEME_VERSION, a version constant for runtime
checks.