Skip to main content
Version: 1.0.3

InfiniteCanvasLayout

The Infinite Canvas Layout template provides the shell behind whiteboard and canvas-style tools (Figma, Miro, tldraw): an optional top toolbar above a full-bleed, pannable and zoomable dot-grid surface. Content is placed with the CanvasNode helper at fixed world coordinates, and the whole layer pans/zooms together via drag, wheel/trackpad, keyboard shortcuts, or the floating zoom controls.

Idea
Sketch
Draft
Review
100%

Installation

ignix add component InfiniteCanvasLayout

Usage

import { InfiniteCanvasLayout, CanvasNode } from '@ignix-ui/infinite-canvas-layout';

Basic Usage

function App() {
return (
<InfiniteCanvasLayout>
<CanvasNode x={0} y={0}>
<div>Idea</div>
</CanvasNode>
<CanvasNode x={320} y={80}>
<div>Sketch</div>
</CanvasNode>
</InfiniteCanvasLayout>
);
}

With a Toolbar

<InfiniteCanvasLayout
header={<span className="font-bold">Board</span>}
actions={<ThemeToggle />}
minZoom={0.25}
maxZoom={2.5}
gridSize={32}
>
<CanvasNode x={0} y={0} width={200} height={120}>
<Card />
</CanvasNode>
</InfiniteCanvasLayout>

Controlled Viewport

import { useState } from 'react';

function App() {
const [viewport, setViewport] = useState({ x: 0, y: 0, zoom: 1 });

return (
<InfiniteCanvasLayout viewport={viewport} onViewportChange={setViewport}>
<CanvasNode x={0} y={0}>
<div>Synced with external state</div>
</CanvasNode>
</InfiniteCanvasLayout>
);
}

Interaction Reference

InputAction
Drag on empty canvasPan the canvas
Mouse wheel / trackpad scrollPan the canvas
Ctrl/Cmd + wheelZoom toward the cursor
Arrow keys (when focused)Pan the canvas
+ / - (when focused)Zoom in / out
0 (when focused)Reset to defaultViewport
Zoom control buttonsZoom in / out / reset

Props

InfiniteCanvasLayout

PropTypeDefaultDescription
headerReact.ReactNodeundefinedCustom node rendered at the start of the top toolbar (e.g. a logo/title)
actionsReact.ReactNodeundefinedOptional node rendered at the end of the top toolbar
childrenReact.ReactNodeCanvas content, typically one or more CanvasNode elements
viewportCanvasViewportundefinedControlled pan/zoom state; provide alongside onViewportChange to drive the canvas externally
defaultViewportCanvasViewportx: 0, y: 0, zoom: 1Initial pan/zoom state when uncontrolled, and the state "Reset view" returns to
onViewportChange(viewport: CanvasViewport) => voidundefinedCalled whenever the viewport changes, whether controlled or not
minZoomnumber0.25Minimum zoom factor
maxZoomnumber2.5Maximum zoom factor
showGridbooleantrueWhether to render the background dot grid
gridSizenumber32Spacing between grid dots, in canvas world units
showControlsbooleantrueWhether to render the floating zoom in/out/reset control panel
classNamestringundefinedAdditional CSS classes applied to the root container

CanvasNode

PropTypeDefaultDescription
xnumberHorizontal position in the canvas's world space
ynumberVertical position in the canvas's world space
widthnumber | stringundefinedOptional fixed width
heightnumber | stringundefinedOptional fixed height
classNamestringundefinedAdditional CSS classes
childrenReact.ReactNodeNode content

CanvasViewport

PropTypeDescription
xnumberHorizontal pan offset, in pixels
ynumberVertical pan offset, in pixels
zoomnumberZoom factor (1 = 100%)