Raft Design System

Components · Layout

PaneGrid

How panes are laid out — columns side by side, a column split top and bottom, a pane folded to its tab bar, and one pane maximized — with sizes in px kept by the caller.

ExperimentalAlso called Split view, Editor grid, Pane layout
import { PaneGrid } from "@botiverse/raft-ui/wip";

PaneGrid lays out panes: columns side by side, or, nested with orientation="vertical", a column split top and bottom. A pane can be folded to its tab bar, and one pane can be maximized. It is built on Resizable; the sizes are px the caller keeps, and the grid only reports a seam someone dragged (Tabs and panes).

pane-grid/compositions/preview

When to use

SituationUse
Panes of tabs beside a conversationPaneGrid, a Pane in each cell
Two columns of an app's own whose split people dragResizable

Anatomy

  • The grid: a ResizableGroup of cells, with a ResizableHandle on each seam.
  • A cell: an id, its saved size in px, its min and max, and its content. fixed folds it to its tab bar: fixed at its size, with no handle on either side. data puts data-* attributes on it for the app's hit-testing.

Behavior

  • onResize gets each cell's new size in px, as asked for before a narrow window clamped it, only when someone drags a seam. A layout the grid makes itself, for a narrower window, never changes the saved sizes.
  • layoutKey changes when the structure changes (a pane added or folded, the window's width): the grid lays out again from the saved sizes.
  • maximized fills the grid with one cell and hides the others; a cell with keepWhenMaximized stays on screen at its size beside it. The maximized cell's content gets the new width.
  • Maximizing, restoring and a new layoutKey lay the grid out anew, so the cells' content mounts again. Keep what must live on outside the grid: the shell lays pages over the panes from a fixed layer, and keeps tabs and drafts in its own state (Tabs and panes).
  • A cell's least size is 160px for a column, a tab bar's height for a folded pane: content under its own least width is clipped, not squeezed.

Accessibility

  • Each seam is a focusable separator: the arrow keys resize. Name it with messages.resize (Resize by default).

Rules

  • Keep up to 4 columns, and each pane split top and bottom at least 200px tall.
  • Save only the sizes people dragged.

API

PaneGrid

ExperimentalHow panes are laid out: columns side by side, a column split top and bottom, and one pane maximized. Built on `ResizableGroup`, `ResizablePanel` and `ResizableHandle`: a seam is a focusable separator the arrow keys move. Sizes are px kept by the caller; the grid only reports a dragged seam.
PropTypeDefault
cells (required)PaneGridCell[]
layoutKey (required)Changes when the cells' structure changes (a pane added or folded, the window's width): the grid lays out again from the saved sizes.string
maximizedOne cell fills the grid; the others are hidden. Maximizing and restoring lay the grid out anew, so the cells' content mounts again: keep what must live on (a page, a draft) outside the grid, as the shell's fixed layer does.stringnull
messagesPartial<PaneGridMessages>
onResizeA seam was dragged: each cell's new size in px. Never called for a layout the grid made itself.(sizes: Record<string, number>) => void
orientationColumns side by side, or one column split top to bottom (a vertical PaneGrid inside a cell)."vertical" | "horizontal""horizontal"