Skip to content
Core

Grids and snapping ​

Loading interactive example…Open in new tab ↗
Opening the live canvas…

Drag a card with Snap on, then compare with Snap off. Hide removes the background without changing snapping. Choose 20 or 40 world units for the shared interval. Dots, lines and the custom cross pattern use that same interval; the custom pattern adds a major line every five intervals.

All controls update the diagram's GridOptions with controller.edits.setOptions(...). They do not rewrite document elements or enter document history. Moving a card remains an ordinary admitted edit and can be undone. Reset restores the fixture and its initial visible, snapping grid.

See Grids API for normalization, layer limits and rotation snapping.

Source ​

dart
void configureGrid(
  DiagramController controller, {
  bool? visible,
  bool? snap,
  double? size,
  DiagramGridPattern? pattern,
}) => controller.edits.setOptions(
  controller.options<GridOptions>().copyWith(
    visible: visible,
    snap: snap,
    size: size,
    pattern: pattern,
  ),
);