Skip to content
EspañolEnglish
All components (283)

Dockable panels

Structure · DockLayout · .amset-dock

What it is and when to use it

A workspace with dockable panels: four areas (left, centre, right and bottom), each with its tabs.

When to use it

  • Tools for long work sessions: a report editor, an operations panel, a support console, where each person places the panels as they like.
  • panels are all the possible panels; the layout (layout or defaultLayout, created with createDockLayout) says which area each one goes in, which one is shown, how big each area is and whether it is collapsed.
  • A panel is taken to another area from its menu or by dragging its tab. The sides and the bottom area resize with their separator and collapse.
  • onLayoutChange hands out the new layout to save it.
  • The panels of an area are shown as tabs or as free columns: all at once, with separators to share out the space. It is switched from the menu of any panel (“Show the panels as columns”) or with arrangeDockArea. storageKey saves the layout on every change and restores it on mount (storage for another store), and dockLayoutToJson and dockLayoutFromJson take it to text and back, sanitised, to keep it wherever you like.

When not to

  • Two or three fixed areas that only resize: ResizablePanels. The frame of an application with a menu and a header: AppShell.

Keyboard: the tabs of each area are traversed with the arrows; each panel's menu offers to move or close it; the separator moves with the arrows, and Home and End take it to the minimum and the maximum.

Accessibility: each area is a named region and its tabs are a real tab group; the separator says its size as a percentage and moving or closing a panel is announced.

Fine appearance: --amset-dock-height, --amset-dock-gap (gap between areas) and --amset-dock-separator (thickness of the separator).

What it looks like

catalogue.pdf · orders.xlsx

925 silver ring with a cubic zirconia.

10:32 · Order #1042 shipped.

<DockLayout
  label="Workspace"
  style={{ width: "100%" }}
  panels={paneles}
  defaultLayout={createDockLayout({
    left: ["archivos"],
    center: ["editor", "notas"],
    bottom: ["consola"],
  })}
/>

Props

Import it with import { DockLayout } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
labelrequiredstringWhich workspace it is («Report editor»). Required.
panelsrequiredreadonly DockPanel[]All the panels that can appear; where each one goes is said by the layout.
classNamestringMerged with the library classes; it does not replace them.
defaultLayoutDockLayoutState—
layoutDockLayoutStateThe layout. If passed, whoever uses it controls it (to save it, for example).
onClose(key: string) => voidWhen a panel is closed from its menu.
onLayoutChange(layout: DockLayoutState) => void—
storageDockStorageWhere it is saved with `storageKey`. `localStorage` by default. See `DockStorage`.
storageKeystringSaves the layout under this key on every change and restores it on mount: what each person has moved, folded, shared out or closed stays. A panel that no longer exists is dropped on restore. Without this nothing is saved (to keep it elsewhere, `onLayoutChange` and `dockLayoutToJson`).

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

CSS variables

These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.

VariableDefault
--amset-dock-height34rem
--amset-dock-gapvar(--amset-space-1)
--amset-dock-separator0.75rem

How to change it

.amset-dock {
  --amset-dock-height: ...;
  --amset-dock-gap: ...;
}

In the test bench

Every state and variant, to try one at a time, on its page at storybook.amsetui.com: