Swatch

Colours
No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/checkbox-swatch

About this component

Colour swatches you can pick several of: four glossy discs. A picked one shrinks inside a ring of its own colour that springs out round it, and a tick pops in at its centre.

Triggers

  • Click
  • State change
  • Spring
  • Border

Techniques

  • CSS variables
  • Radial gradient
  • SVG
  • CSS transition

Difficulty

Beginner

Accessibility

Keyboard and screen readers

A <fieldset> with a visually hidden <legend> ("Colours"); each swatch is a <label> round a native checkbox named by aria-label ("Coral", "Amber", "Teal", "Violet"). The ring and disc are aria-hidden, and :focus-visible on the input outlines the ring.

Reduced motion

Every transition and animation is switched off, so it jumps straight to its final state.

Use it in anything you build, commercial and client work included. Licence

More checkboxes

See all
TarmacGet code
TerrazzoGet code
UrushiGet code
Repeat on
WeekdaysGet code