Drawing Cursor
A canvas layer where the pointer draws a decaying, taper-aware stroke over your content.
Installation
npx smoothui-cli add drawing-cursorFeatures
- Freehand ink trail rendered on a
<canvas>overlay as the pointer moves - Speed-aware
taper— faster strokes get thinner, slower strokes get thicker - Per-point
decayso old ink fades and is dropped once fully transparent (or stays permanent whendecayis0) - Quadratic
smoothingfor a hand-drawn curve instead of jagged segments - Configurable
blend(GlobalCompositeOperation) for ink, neon, or eraser looks - Imperative
refAPI (clear(),toDataURL()) using React 19'sref-as-prop pattern — noforwardRef - Canvas sized with
ResizeObserver, capped at 2x device pixel ratio - Coalesced pointer events are read where the browser supports them, for a smoother line at high polling rates
Accessibility
ARIA Attributes
| Attribute | Element | Purpose |
|---|---|---|
aria-hidden="true" | <canvas> | Hides the purely decorative ink layer from assistive technology |
pointer-events-none | <canvas> | Ensures the canvas never intercepts clicks, taps, or focus from children |
Screen Reader
- The canvas is
aria-hiddenand non-interactive; it draws on top ofchildrenbut never in front of them for input purposes. Everything underneath remains focusable, clickable, and readable exactly as if the component were not present.
Reduced Motion
When prefers-reduced-motion is set, or on touch/coarse-pointer devices
(detected via matchMedia("(hover: hover) and (pointer: fine)")), the
<canvas> is not mounted at all — no listeners are attached and children
render normally with zero drawing overhead.
Props
Created by
Powered by
© 2026 SmoothUI. Built by Eduardo Calvo.