Flutter docs
Default skin

Diagram Composition

A read-only drawing of nodes joined by arrows, on a grid. It renders a diagram the caller already has; editing one is DiagramEditor, a separate interaction contract.

Usage

Scroll or drag the background to pan. Pinch, Ctrl + scroll or the controls zoom.

  • Draft
    • → Review
  • Review
    • → Approved: Yes
    • → Rework: No
  • Approved
  • Rework

Interaction contract

The drawing runs on the React Flow runtime (@xyflow/react), which owns the viewport: drag the background to pan, scroll or pinch to zoom, and use the controls to zoom or fit. Nothing in the drawing is draggable or editable. By default nothing is focusable or selectable either; give renderInspector and a reader can choose a node or edge, by click or by focusing it and pressing Enter or Space, to read about it in a panel beside the canvas (below it on a narrow screen), the same panel DiagramEditor uses. The viewport is a named region described by an outline list — every node with the edges leaving it — so assistive technology reads the diagram as a list.

Positions are grid cells chosen by the caller, and one cell is one --cb-space-5. The component does no layout and gives nodes and edges no meaning: a shape and a Tone are visual treatment only.

Do

Use it to show a process or dependency that readers follow by position and arrows.

Don't

Use it for data that has an axis or a scale — that is a Chart, outside this library.

Loading

Diagram.Skeleton keeps the viewport geometry while the diagram loads, without inventing node positions.

Props

PropTypeDefaultNotes
labelstring—Accessible name for the diagram viewport.
nodesDiagramNode[]—id, label, position in grid cells, optional shape (rect | pill | diamond), tone and static content.
edgesDiagramEdge[]—id, from, to, optional label and tone. An edge naming a missing node is not drawn.
hintstring—Optional visible guidance above the viewport.
outlineLabelstringDiagram outlineAccessible name for the outline list.
ariaLabelsPartial<AriaLabelConfig>—Localised names for the runtime’s own controls.
legendLabelsPartial<Record<DiagramShape, string>>—Names for the node shapes; given, a legend lists the shapes in use.
renderInspector(selection: DiagramSelection | null) => ReactNode—Opt-in reading panel. Receives the chosen node (with its incoming and outgoing links) or edge, or null when nothing is chosen.
inspectorLabelstringSelectionAccessible name for the reading panel.

Keyboard

KeyResult
TabReaches the zoom and fit controls; with renderInspector, also each node and edge
Enter / SpaceWith renderInspector, chooses the focused node or edge for the panel

The controls use the shared control floor and show the theme's focus ring inside each button.

Tokens

--cb-space-5 (one grid cell), --cb-canvas-block-size, --cb-surface, --cb-border*, --cb-tone-*, --cb-fg*, --cb-radius-* and --cb-text-*.