Give the Workspace a size, a model, and a stable function for the content of each tab.
editor-layout.tsx
Workspace
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | — | CSS class name. |
| id | string | — | Uniquely identifies this workspace within an application. Falls back to useId when not provided. ℹ️ This value will also be assigned to the id and data-testid attributes; (an explicit data-testid prop will take precedence). |
| style | CSSProperties | — | CSS properties. |
| class | WorkspaceClassNames | — | CSS class names for the elements the workspace renders within its root element: - tabset: root element of a tabset (data-tabset) - header: contains a tabset's tab list and toolbar (data-tabset-header) - tabList: contains a tabset's tabs (data-tab-list) - tab: passed to renderTab with the rest of a tab's props (data-tab) - toolbar: contains the content returned by renderTabsetToolbar (data-tabset-toolbar) - tabPanels: contains a tabset's tab content (data-tab-panels) - tabContent: the element each tab's content is rendered into (data-tab-content) - dropIndicator: shows where a dragged tab will be dropped within a tabset's panels (data-drop-indicator) - dragPreview: follows the pointer while a tab is dragged (data-drag-preview) ℹ️ Elements expose their state as data attributes (e.g. data-tab-selected), which can be used for styling. Elements within a tabset also have a data-tab-placement attribute (see tabPlacement). ℹ️ Like the render props, this object is part of what tabsets re-render for; in large workspaces, define it outside of the component (or memoize it) rather than inline. |
| default | WorkspaceModelInput<TabData, TabsetData> | — | Initial layout of the workspace. ℹ️ Splits and tabsets may omit their ids; they're assigned ids based on their position (see WorkspaceModelInput). ℹ️ This value is only used when the Workspace mounts; use the imperative setModel method to replace it later. |
| disabled | boolean | — | Locks the arrangement: tabs cannot be resized, dragged, dropped, or closed by the user. Selecting tabs and maximizing tabsets still work. ℹ️ This prop overrides the disableClose and disableDrag flags of individual tabs. |
| disable | — | Prevents tabs from being dropped onto some (or all) targets. Functions are called when the target under the pointer changes; returning true rejects the target. | |
| element | Ref<HTMLDivElement | null> | — | Ref attached to the root HTMLDivElement. |
| on | — | Called after the model has changed (e.g. a tab was moved, selected, or closed, or a tabset was resized). ℹ️ For changes caused by pointer events, this method is not called until the pointer has been released. This method is recommended when saving models to some storage api. | |
| render | — | Content of the element that follows the pointer while a tab is being dragged. Defaults to the tab's title (or id). | |
| render | — | Content shown in the panels of a tabset that has no tabs (e.g. "Drag a tab here"): the root tabset of an empty workspace, or a tabset with the keepWhenEmpty flag. | |
| render | — | Separator rendered between the children of a split. Should return a Separator (or null for no separator); defaults to an unstyled Separator. ℹ️ Without separators, tabsets can still be resized by dragging their edges (like Panels in a Group without separators), but separators are recommended: they can be resized with the keyboard, and an edge's hit area can overlap the tabs beside it (pressing there resizes the tabset rather than dragging the tab). | |
| render | — | Renders a tab (within its tabset's tab list). Spread props onto the returned element: they make it a tab (its role and ARIA attributes, keyboard and pointer handling, and data attributes), and attach a ref that dragging and keyboard focus depend on. ``tsx renderTab={(tab, props) => ( <div {...props}> {tab.title} <TabCloseButton /> </div> )} ` Individual props can be overridden or wrapped, e.g. to confirm before the Delete key closes a tab (call props.onKeyDown for other keys). ⚠️ Merge className and style rather than replacing them (e.g. style={{...props.style, padding: 4 }}): they include the tab entries of the classNames and styles props, and style includes the touch-action that touch dragging depends on. ℹ️ Pointer and keyboard events from interactive descendants (button elements, role="button", or elements with a data-tab-ignore attribute) are ignored, so clicking a button within a tab doesn't select or drag it. ℹ️ When this prop is not provided, tabs show their title (or id) followed by a TabCloseButton`. | |
| render | — | Content shown after a tabset's tab list (e.g. buttons to add a tab or maximize the tabset). ℹ️ The useParentTabset and useParentTabsetState hooks can be used within this content. | |
| resize | "panel""separator" | "panel" | Controls whether pointer dragging updates sizes immediately, or renders overlay separator previews until the pointer is released. |
| server | false | Render the content of selected tabs on the server. Can be a function to choose per tab (e.g. based on its data). Tab content is rendered through portals (so that moving a tab doesn't remount it), which React can't render on the server. Content opted into server rendering is rendered inline instead, then moved into a portal once hydration has finished. ⚠️ That move remounts the content once (e.g. resetting its state and re-running its effects), so this is best suited to content that is cheap to mount and benefits from being in the server-rendered HTML. ℹ️ This prop has no effect for workspaces that are not server rendered. | |
| styles | WorkspaceStyles | — | CSS properties for the elements the workspace renders within its root element (see classNames). |
| tab | "bottom""left""right""top" | "top" | Where tabs are placed relative to tab content. Tabs placed on the left or right are stacked ("vertical"): this determines how a dropped tab's position is found and which arrow keys move focus between tabs. ℹ️ Elements within a tabset have a data-tab-placement attribute, which can be used for styling (e.g. rotating tabs on the left or right). ℹ️ Tabsets can override this with the tabPlacement field of their model node. |
| tabset | string | — | Minimum height of each tabset's content area (not including its header). ℹ️ Tabsets can override this with the minHeight field of their model node. ℹ️ Interpretation rules: - Strings must specify a unit: "px", "em", "rem", "vh", or "vw" (e.g. tabsetMinHeight: "200px") - Percentages (and strings without units) are not allowed |
| tabset | string | — | Minimum width of each tabset's content area (not including its header). ℹ️ Tabsets can override this with the minWidth field of their model node. ℹ️ Interpretation rules: - Strings must specify a unit: "px", "em", "rem", "vh", or "vw" (e.g. tabsetMinWidth: "200px") - Percentages (and strings without units) are not allowed |
| workspace | — | Exposes the imperative API (see WorkspaceImperativeHandle). ℹ️ The useWorkspaceRef and useWorkspaceCallbackRef hooks are exported for convenience use in TypeScript projects. | |
| render | — | The content of a tab. Keep it stable (useCallback): a new function renders every tab again. | |
| labels | Partial<{ separator: string; }> | — | The words of the Workspace (WORKSPACE_LABELS). Translate them. Keep the object stable. |
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
WorkspaceTab
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ref | RefCallback<HTMLElement> | — | |
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
WorkspaceTabClose
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>. |
WorkspaceToolbarButton
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| glass | "clear""dark""light" | — | |||||
| rounded | "default""full" | — | |||||
| size | "default""icon""icon-lg""icon-sm""icon-xs""lg""sm""xl""xs" | — | |||||
| variant | "dashed""default""destructive""destructive-outline""ghost""link""media""outline""secondary" | — | |||||
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
WorkspaceMaximizeButton
<button>| Prop | Type | Default | Description | ||||
|---|---|---|---|---|---|---|---|
| class | string | — | |||||
| busy | boolean | — | The button waits for the app (busy words): a spinner, aria-busy, and no clicks. Focus stays on the button. The style hook stays data-loading. | ||||
| spinner | "center""start" | — | center (default): the spinner covers the label. start: it takes the leading icon slot. The icon sizes always use center, because their one icon is the label. | ||||
| glass | "clear""dark""light" | — | |||||
| rounded | "default""full" | — | |||||
| size | "default""icon""icon-lg""icon-sm""icon-xs""lg""sm""xl""xs" | — | |||||
| variant | "dashed""default""destructive""destructive-outline""ghost""link""media""outline""secondary" | — | |||||
| labels | { maximize: string; restore: string; } | DEFAULT_MAXIMIZE_LABELS | Names of the two states. Translate them. | ||||
From Base UIButtonBase UI docs | |||||||
| focusable | boolean | false | Whether the button should be focusable when disabled. | ||||
| render | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. | |||||
| style | — | Style applied to the element, or a function that returns a style object based on the component's state. | |||||
| |||||||
| ...props | <button> attributes | — | Every other attribute goes to the <button>, with a ref. | ||||
WorkspaceEmpty
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
WorkspaceEmptyHeader
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
WorkspaceEmptyTitle
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
WorkspaceEmptyDescription
<div>| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | <div> attributes | — | Every other attribute goes to the <div>, with a ref. |
| Arrow Left / Arrow Right / Home / End | Move between the tabs of a tabset. |
|---|---|
| Enter | Select the focused tab. |
| Delete | Close the focused tab. |
| AltArrow | Move the focused tab one place along its tab list. |
| AltShiftArrow | Split the focused tab into a new tabset on that side. |
| Arrow Left / Arrow Right / Arrow Up / Arrow Down | On a focused line between tabsets: resize the tabsets on both sides. |
Built with
Installs with Workspace











