photocn

Search

Search the docs

0

Canvas

Shows the photo. In the crop tool it shows the crop frame, and everywhere else the edited result.

"use client";

import { ImageEditorProvider } from "photocn/react";

import { ImageEditorCanvas } from "@/components/image-editor/canvas";

// Scroll with ⌘/Ctrl or pinch to zoom · press and hold to see the original ·
// drop another photo onto it.
export default function CanvasDemo() {
  return (
    <ImageEditorProvider src="/samples/mountain-lake.jpg">
      <ImageEditorCanvas className="h-[420px] rounded-xl border p-2" />
    </ImageEditorProvider>
  );
}

Installation

pnpm dlx shadcn@latest add @photocn/image-editor-canvas

Usage

import { ImageEditorCanvas } from "@/components/image-editor/canvas";

<ImageEditorProvider src="/photo.jpg">
  <ImageEditorCanvas className="h-96" />
</ImageEditorProvider>

Props

PropTypeDescription
classNamestringClasses for the outer element.
altstringAccessible name for the image.
allowDropbooleanOpen images dropped onto it. Default true.
showOpenButtonbooleanShow the Open button when there's no image. Default true.
emptyStateReactNodeWhat to show before an image is loaded.
paddingnumberSpace around the photo in px. Default 24.
childrenReactNodeYour own layers, drawn over the photo.