Skip to content
SENVENLI UI

Color swatch picker

Preset colors as named swatches, optionally ending with a button that opens a color picker for a custom color.
Preset colors
import { ColorSwatchPicker } from "@senvenli/react/color";

Examples

With a custom color

The last button opens a color picker for a color outside the presets.

Guidelines

When to use it

  • Choosing from a small set of preset colors.

Use something else when

  • Any color is allowed and presets are a shortcut at most. Color picker

Accessibility

Keyboard

KeysWhat happens
Arrow keysMove between swatches.

Built in

  • Each swatch is named; the caption names the selection.

You provide

  • A label and a name for each preset.

API reference

ColorSwatchPicker

labelRequired
React.ReactNode

"Theme presets".

itemsRequired
readonly ColorSwatchItem[]

The preset colors; check them with checkBrandColor so that only a custom color can fail.

value
string

The chosen color, controlled. null or "": none chosen, so no swatch shows a check (a theme with no brand color).

defaultValue
string
onChange
(value: string) => void
allowsCustom
boolean

Ends with a button that opens ColorPicker for a custom color.

description
React.ReactNode

Under the swatches, after "Ocean · selected".