logo

X6

  • Tutorials
  • API
  • Examples
  • Q&A
  • Change Log
  • XFlow
  • Productsantv logo arrow
  • 2.x
  • start
    • Introduction
    • Quick Start
  • component
    • XFlowGraph Canvas
    • Background
    • Grid
    • Clipboard Copy and Paste
    • History Undo Redo
    • Minimap
    • Snapline Alignment Lines
    • Transform
    • Control Controller
  • Hook
    • useGraphInstance
    • useGraphStore
    • useGraphEvent
    • useDnd
    • useClipboard
    • useExport
    • useHistory
    • useKeyboard
  • Store

Grid

Previous
Background
Next
Clipboard Copy and Paste

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-Interactive solution
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Canvas Grid

Basic Usage

Note

The <Grid /> component can only be used properly within the <XFlow /> component.

After importing the <Grid /> component, you can set the canvas grid for <XFlowGraph />.

<XFlow>
...
<Grid type="mesh" options={{ color: '#ccc', thickness: 1 }} />
</XFlow>

Grid Size

You can control the grid size by setting the size property. The default grid size is 10px, which means that when rendering nodes, they will align to the grid with 10 as the minimum unit. For example, a node positioned at { x: 24, y: 38 } will actually render at { x: 20, y: 40 } on the canvas. When moving nodes, the minimum distance moved will be 10px.

Hide Grid

You can hide the grid by adding the visible property.

Dot Grid

The dot grid, with the type property set to dot, allows you to set the grid color and width through the options property.

Fixed Dot Size Grid

The fixed dot size grid, with the type property set to fixedDot, allows you to set the grid color and width through the options property. Note: When the canvas zoom level is less than 1, the dot size scales with the canvas zoom level. When the canvas zoom level is greater than 1, the dot size is fixed to the given thickness value.

Mesh Grid

The mesh grid, with the type property set to mesh, allows you to set the grid color and width through the options property.

Double Mesh Grid

The double mesh grid, with the type property set to doubleMesh, allows you to set the color and width of the primary and secondary grid lines through the options property.

API

Grid

Parameter NameDescriptionTypeDefault Value
visibleWhether the grid is displayedbooleantrue
sizeGrid sizenumber10
typeGrid typedot | fixedDot | mesh | doubleMesh-
optionsGrid parameters corresponding to the grid typeargs | args[]-

The options corresponding to the args parameters are as follows:

Parameter NameDescriptionTypeDefault Value
colorGrid line colorstring-
thicknessGrid line width or dot sizestring-
factorInterval between primary and secondary grid lines, only effective when type is doubleMeshnumber-