v1.0
Guides / Page 02·02

Flow grids

Learn how to use flow grids for Kanban and ordered layouts.

A flow grid keeps widgets in order and packs them densely, like a list. Set a target’s layout.type to 'flow' to get one:

Svelte 1D Flow Grid
Press Enter to grab or resize widgets. Once grabbed, use Arrow keys to move/resize the widget, Enter to confirm the action, or Esc to cancel it.
I'm at (0, 0)
And I'm at (0, 1)

Both widgets sit in a single column. Drag one onto the other and they swap; drop into an empty cell and the rest reflow to close the gap.

When to use a flow grid

Use a flow grid when order matters more than position: Kanban columns, sortable lists, and galleries. Widgets never have gaps between them, and a widget dropped into the grid takes an index rather than coordinates. For dashboards where widgets live at fixed coordinates, use a free-form grid.

Configuring the flow

Three properties shape a flow grid:

  • flowAxis chooses whether widgets run along rows ('row') or columns ('column').
  • placementStrategy decides where a widget lands when it is added without a position: 'append' at the end, 'prepend' at the start.
  • rows and columns fix the grid’s size. Leave one open and the grid grows along the flow axis, capped by maxFlowAxis if you set it.

Every property, with its type and default, is in the FlowTargetLayout reference.

Extension to 2D

When the cross dimension (columns for row flow, rows for column flow) is greater than 1, the flow wraps across it. Widgets fill the cross dimension as far as they can while keeping their order, so a widget that cannot fit in the current row leaves a gap and starts the next one.

Below, widget B has a width of 2, so it always takes a row of its own. Placed after A or C, it would not fit beside them.

Svelte 2D Flow Grid
Press Enter to grab or resize widgets. Once grabbed, use Arrow keys to move/resize the widget, Enter to confirm the action, or Esc to cancel it.
A
B
C

Examples

The Notes example uses nested 1D flow grids, and Flow is a 2D flow grid.

Gotchas

  • Flow-axis size is always 1. A widget’s height in row flow (or width in column flow) is ignored. With rowSizing or columnSizing set to auto, cells still stretch to fit content of different sizes.
  • Drop targets are whole cells. Dropping onto a widget places the dragged widget after it when moving forwards and before it when moving backwards. Changing side on the same widget needs real pointer travel, so widgets reflowing under a still pointer never flicker.
  • Insertion can be disabled. Set disallowInsert: true and every drop uses placementStrategy instead of the pointer position, which suits “add to end” inboxes.