Color selector
color-selectorA row of colour swatches where exactly one is chosen. Real radio inputs inside a fieldset, so forms, required state, arrow keys and screen-reader grouping all work natively, and one selection ring hops between swatches.
"use client";
import { useState } from "react";
import {
ColorSelector,
ColorSelectorItem,
ColorSelectorLabel,
ColorSelectorList,
} from "@/components/forme/color-selector/color-selector";
const BRAND_COLOURS = [
{ value: "#3478f6", color: "#3478f6", label: "Blue" },
{ value: "#8b5cf6", color: "#8b5cf6", label: "Violet" },
{ value: "#ec4899", color: "#ec4899", label: "Pink" },
{ value: "#ef4444", color: "#ef4444", label: "Red" },
{ value: "#f59e0b", color: "#f59e0b", label: "Amber" },
{ value: "#10b981", color: "#10b981", label: "Emerald" },
];
export function ColorSelectorDemo() {
const [colour, setColour] = useState("#3478f6");
return (
<div className="flex flex-col gap-8">
<ColorSelector value={colour} onValueChange={setColour}>
<ColorSelectorLabel>Accent colour</ColorSelectorLabel>
<ColorSelectorList>
{BRAND_COLOURS.map((preset) => (
<ColorSelectorItem
key={preset.value}
value={preset.value}
color={preset.color}
label={preset.label}
/>
))}
</ColorSelectorList>
</ColorSelector>
<p className="text-caption-1-regular text-muted-foreground">
Selected: <span className="font-mono text-foreground">{colour}</span>
</p>
<ColorSelector defaultValue="#10b981" name="surface">
<ColorSelectorLabel>Surface tint</ColorSelectorLabel>
<ColorSelectorList>
{BRAND_COLOURS.slice(0, 4).map((preset) => (
<ColorSelectorItem
key={preset.value}
value={preset.value}
color={preset.color}
label={preset.label}
/>
))}
<ColorSelectorItem value="muted" color="var(--muted)" label="Neutral" disabled />
</ColorSelectorList>
</ColorSelector>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import {
ColorSelector,
ColorSelectorItem,
ColorSelectorLabel,
ColorSelectorList,
} from "@/components/forme/color-selector/color-selector";
<ColorSelector defaultValue="#3478f6" name="accent">
<ColorSelectorLabel>Accent colour</ColorSelectorLabel>
<ColorSelectorList>
<ColorSelectorItem value="#3478f6" color="#3478f6" label="Blue" />
<ColorSelectorItem value="#ec4899" color="#ec4899" label="Pink" />
</ColorSelectorList>
</ColorSelector>When to use
Reach for it
- A fixed palette of six or so colours, where seeing them side by side is the point.
nameon the group rather than per item: the inputs share it, so the browser submits one value and enforcesrequiredfor you.coloras a CSS custom property when the swatches should follow the theme instead of being fixed hex values.
Use something else
- Arbitrary colour choice — reach for a
ColorPicker; a swatch row cannot express a colour it does not contain. - Relying on the swatch colour to carry meaning: every item still needs a
label, because colour alone is not a name.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
ColorSelector
A row of colours where exactly one is chosen.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | The selected value, for controlled use. |
defaultValue | string | "" | The initial value when uncontrolled. Default "" |
onValueChange | (value: string) => void | — | Called with the item's value when the selection changes. |
name | string | — | The radio name used in form submission. Generated when omitted. |
required | boolean | false | Requires a choice before the form submits. Default false |
disabled | boolean | false | Dims the whole group and stops every swatch from being picked. |
Also takes every prop of <fieldset> attributes.
ColorSelectorItem
| Prop | Type | Default | Description |
|---|---|---|---|
value* | string | — | The value reported and submitted when this colour is picked. |
color* | string | — | Any CSS colour, including a custom property. |
label* | string | — | Accessible colour name. The selection never relies on colour alone. |
className | string | — | Applied to the visible swatch surface. |
Also takes every prop of <input> attributes.
The other parts
ColorSelectorLabelTakes<legend>attributesColorSelectorListTakes<div>attributes
Accessibility
- Native radios in a fieldset with a legend, so the group is announced, arrow keys move and select, and the browser validates
required. - Focus lands on the visually hidden input and is drawn on the swatch with
peer-focus-visible, so the ring the user sees is the control they are on. - Every item requires a
label; the visible swatch isaria-hidden, so the name never depends on colour.
Motion
- The selection ring is one shared element that hops along an arc, so the change reads as a move rather than a second swatch turning on.
- The press scale is the only other motion; reduced motion removes the hop and the scale and keeps the selection itself.
Responsive behaviour
- The list wraps, so a narrow container becomes two rows instead of overflowing.
size-11swatches sit on the 44px touch target; a tighter row should keep 44px of vertical space even if the visual circle shrinks.
Related
Color picker
A full colour editor: a saturation and brightness area, hue and opacity rails, a hex field, numeric channels, screen sampling and preset swatches — all composed from parts, opened from a trigger chip that previews the value.
inputs

Calendar
A month grid for a single date or a range, with no date library. Full WAI-ARIA keyboard support, month and year pickers, min, max and disabled days, a range that previews under the pointer or the keyboard, and a fixed six-week height so nothing below it jumps.
inputsDate Range Picker
A button that opens a calendar for a date range: the range said in words on the trigger, a day count, Clear and Done, and optional presets. Ranges can refuse disabled days inside them, for bookings.
inputs