StealThis .dev

Storybook — Coloring / Paint Canvas

A friendly coloring activity for a children's storybook app, built entirely from inline SVG and vanilla JavaScript. A chunky crayon palette drives a flood-fill canvas where tapping or dragging across a hand-drawn fox scene paints each region with the active color, complete with a gentle pop animation. It ships with a ten-crayon box, a rainbow mode that cycles hues on every fill, undo and clear controls, an active-crayon readout, and a save-to-PNG export rendered through a canvas — all keyboard friendly and reduced-motion aware.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Coloring / Paint Canvas

A no-mess coloring book page rendered with a single inline SVG: a waving fox on a hill beneath the sun, drawn as fillable regions sitting under a layer of thick ink outlines. Coloring is flood-fill by region rather than freehand — tap any shape to flood it with the active crayon, or hold and drag the pointer across the picture to splash color over every region you sweep. Each fill lands with a soft pop, and the face details and outlines stay crisp on top because they are not paintable.

A chunky two-up crayon box offers ten storybook colors and behaves as a proper radiogroup: click a crayon or arrow-key between them, and the lifted, ringed crayon plus the live active-crayon chip below the canvas always show what you are about to paint with. The rainbow button flips into a special mode where every fill steps through the next color of the spectrum, so a single drag leaves a banded streak.

Undo walks back one fill at a time by restoring each region’s previous color, Clear resets the whole page to blank, and Save picture rasterizes the SVG onto a 2x canvas and downloads it as a PNG. The whole thing is keyboard usable — focus a region and press Enter or Space to fill it — respects reduced-motion preferences, and collapses from a sidebar palette to a stacked, full-width layout on small screens.

Illustrative kids’ UI only — fictional stories, characters, and audio.