ValyroUI Русская версия

Inpaint Canvas

Inpainting mask and canvas outpainting. Pro · Image generation › Results and editing

Mask painting (brush, eraser, rectangle, lasso, pen pressure), undo/redo, zoom/pan and outpainting with PNG export.

Installation

npx valyro-cli@latest login
npx valyro-cli@latest add inpaint-canvas
npm install valyro-ui-pro

import 'valyro-ui-pro/styles.css';
import { InpaintCanvas } from 'valyro-ui-pro';

Props

PropTypeDefault
srcstringImage URL (needs CORS for export when cross-origin). Without it a procedural image is painted from prompt + seed.
promptstring''Prompt the procedural stand-in is painted from when there is no src.
seednumber0Seed of the procedural stand-in.
width *numberWorking size of the image in pixels.
height *numberWorking height of the image in pixels; the mask is exported at this size (plus any extension).
tool'brush' | 'eraser' | 'rectangle' | 'lasso' | 'pan'Controlled tool; use with onToolChange.
defaultTool'brush' | 'eraser' | 'rectangle' | 'lasso' | 'pan''brush'Initial tool when uncontrolled.
onToolChange(tool: InpaintTool) => voidCalled with the new tool when it changes.
brushInpaintBrushControlled brush; use with onBrushChange.
defaultBrushPartial<InpaintBrush>Initial brush when uncontrolled.
onBrushChange(brush: InpaintBrush) => voidCalled with the new brush when it changes.
maskColorstringControlled maskColor; use with onMaskColorChange.
defaultMaskColorstringInitial maskColor when uncontrolled.
onMaskColorChange(color: string) => voidCalled with the new maskColor when it changes.
maskColorsreadonly InpaintMaskColor[]DEFAULT_MASK_COLORSSwatches for the mask overlay color; the first is the initial color when none is given.
overlayOpacitynumber0.55Opacity of the mask overlay. Default 0.55.
outpaintbooleantrueEdge handles that extend the canvas. Default true.
extentExtentControlled extent; use with onExtentChange.
defaultExtentExtentNO_EXTENTInitial extent when uncontrolled.
onExtentChange(extent: Extent) => voidCalled with the new extent when it changes.
extendStepnumber64Snap of the extension. Default 64.
maxExtendnumber512Largest extension per side. Default 512.
initialMaskstringMask to start from, as an image URL (a saved mask or a data URL): white is regenerated, black is kept. Painted once for each image, scaled to it; needs CORS when cross-origin. Undo doesn't go before it.
onMaskChange(info: { empty: boolean }) => voidCalled after every committed edit: whether anything is masked or extended.
apiRefRef<InpaintCanvasApi>Receives the canvas handle: export the image and mask as PNGs, undo / redo, clear, invert, fit, isEmpty.
actionsReactNodeExtra controls at the end of the toolbar, e.g. a Generate button.
stageHeightnumber | stringHeight of the drawing area. By default clamp(320px, 60vh, 620px), but never taller than the image needs at the current width (so a phone shows no empty band around it).
localestringBCP 47 locale for numbers and dates; defaults to the ThemeProvider's, then the browser's.
labelsPartial<InpaintCanvasLabels>Overrides for the built-in English text; keys left out keep their defaults.

Related components

Previous: Image Compare · Next: Generation History · All Image generation