Canvas

A freehand drawing surface with pen and eraser tools, color palette, variable stroke widths, undo/redo, and PNG download.

Installation

npx @obi/ui add canvas

Preview

Usage

import { Canvas } from '@/src/components/Canvas/Canvas';

export default function Example() {
  return (
    <Canvas
      height={400}
      defaultColor="#18181b"
      defaultStrokeWidth={4}
    />
  );
}

Props

NameTypeDefaultDescription
widthnumbercontainer widthCanvas width in px. Defaults to responsive container width.
heightnumber400Canvas height in px.
defaultColorstring'#18181b'Initial stroke color.
defaultStrokeWidthnumber4Initial stroke width in px.
showToolbarbooleantrueWhether to render the built-in toolbar.
classNamestring""Extra classes on the wrapper div.