Skip to content

    Browse components

    Infinite Canvas

    A bounded moodboard-style canvas on a dotted grid: drag to pan with inertia, scroll or pinch to zoom around the pointer, keyboard friendly.

    Open
    Customize

    Installation

    npx shadcn@latest add @glint-ui/infinite-canvas

    First time using @glint-ui? Add the registry to components.json once, or install by URL: npx shadcn@latest add https://glintui.vercel.app/r/infinite-canvas.json

    Usage

    import { InfiniteCanvas } from "@/components/ui/infinite-canvas";
    
    <div className="h-[600px]">
      <InfiniteCanvas
        items={[
          { id: "a", x: 0, y: 0, content: <Card title="Start here" /> },
          { id: "b", x: 400, y: 120, content: <img src="/shot.jpg" alt="" /> },
        ]}
      />
    </div>

    Props

    PropTypeDefaultDescription
    itemsReactNode—Array of { id, x, y, content }, positioned by their center in world px.
    defaultZoomnumber0.8Zoom at first render and on reset.
    minZoomnumber0.3Smallest zoom.
    maxZoomnumber2.5Largest zoom.
    worldWidthnumber2400World width in px; panning stops at its edges.
    worldHeightnumber1600World height in px.
    gridGapnumber24Px between grid dots at 100%.
    dotSizenumber1.1Grid dot radius in px.
    inertiabooleantrueGlide after a flick.
    showControlsbooleantrueShow the zoom buttons.
    labelstring—Accessible name for the canvas.
    classNamestring—Extra classes for the root element.