SlideCanvas
A fixed-ratio slide stage that scales to fit, with free-positioned elements you can select, drag, resize, and nudge with the keyboard.
Installation
npx dafink-ui add slide-canvasDemo
Q3 2026
Quarterly review
Growth, retention, and what is next
Props
| Name | Type | Default | Description |
|---|---|---|---|
| elements | T[] (T extends SlideElement) | - | Elements on the slide: `{ id, label, x, y, width, height }` in logical px, plus any fields of your own. Array order is stacking order. |
| onElementsChange | (elements: T[]) => void | - | Called with the updated array on move, resize, or delete. |
| renderElement | (element: T, state: { selected, editing }) => ReactNode | - | Renders an element. Content is non-interactive unless the element is being edited. |
| renderToolbar | (element: T, state) => ReactNode | - | Floating toolbar shown above the selected element at normal size. Alt+F10 focuses it. |
| width | number | 1280 | Logical slide width. The stage scales to fit its container. |
| height | number | 720 | Logical slide height. |
| stageStyle | CSSProperties | - | Styles on the stage only (not the toolbar), e.g. token variables that theme the slide. |
| backdrop | ReactNode | - | Decorative layer behind the elements (e.g. an ambient effect). Hidden from assistive tech, never interactive. |
| scale | number | - | Fixed zoom (1 = 100%). Omit to fit the container width. |
| onScaleChange | (scale: number) => void | - | Reports the effective scale, e.g. for a zoom percentage. |
| background | string | - | Any CSS background for the stage. Defaults to the surface token. |
| gridSize | number | - | Snap moves and resizes to this grid, in logical px. |
| snapToElements | boolean | true | Snap pointer drags to other elements' edges and centers, with guide lines. Hold Alt to bypass. |
| selectedId | string | null | - | Controlled selection. Omit to let the canvas manage it. |
| onSelectedIdChange | (id: string | null) => void | - | Called when the selection changes. |
| canEdit | (element: T) => boolean | - | Which elements can enter editing mode (double-click or Enter). Omit to disable editing. |
| editingId | string | null | - | Controlled editing element. Omit to let the canvas manage it. |
| onEditingIdChange | (id: string | null) => void | - | Called when editing starts or stops. |
| drawing | boolean | false | Draw mode: pointer drags draw a new region (crosshair + dashed preview) instead of moving elements. |
| onDraw | (from: SlidePoint, to: SlidePoint) => void | - | Called when a draw-mode drag ends, with grid-snapped points in slide px. |
| readOnly | boolean | false | Presentation mode: no selection, dragging, resizing, or keyboard editing. |
| className | string | '' | Additional classes on the outer frame. |
Accessibility
Each element is a focusable role="button" named by its label, with aria-pressed reflecting selection. Elements sit in the normal Tab order (stacking order), and focusing one selects it, so everything a pointer can do (move, resize, delete) is also available from the keyboard. After each keyboard move or pointer drag, a polite live region announces the element's new position and size. The corner resize handles are pointer-only and hidden from assistive tech; Alt + Arrow keys resize instead.
| Key | Function |
|---|---|
| tab | Moves to the next element and selects it. |
| arrow | Moves the element 1px, or one grid step when gridSize is set. |
| shift+arrow | Moves the element 10px. |
| alt+arrow | Resizes the element from its bottom-right corner. |
| enter | Enters editing mode on an editable element, so keys go to its content. |
| alt+f10 | Moves focus into the floating toolbar, when there is one. Escape returns to the element. |
| delete | Removes the element. |
| escape | Exits editing mode, or clears the selection when not editing. |