Skip to content
Calm motion: animations on this site only fade, with no movement

Color swatches ​

A set of ready colors, to pick one

Lets a person pick one color from a short set, for example a label color or a cover color. For any color, use the color picker, which shows these swatches as its presets.

Basic

Cover color: #a759ff

  • swatches is a list of CSS colors, or of { value, label }. Give each color a label, so a screen reader says "Pink" and not a hex code. The label is also the tooltip.
  • v-model is the value of the picked color, or null. The match ignores case, so #E85078 picks #e85078.
  • The picked color has a ring in the text color. size is md (default) or sm.
  • The swatches are a group of native radio buttons: Tab goes into the group, and the arrow keys move between the colors. disabled turns all of them off.
  • Change the name of the group with labels or a label pack: label.

Usage ​

ts
import { BlessColorSwatches, type BlessColorSwatch } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
swatches*(string | BlessColorSwatch)[]—the colors: a CSS color, or `{ value, label }` so a screen reader says a name, not a code
size"md" | "sm""md"
disabledboolean—
labelsPartial<{ label: string; }>—
modelValuestring | nullnull

Events

NamePayloadDescription
update:modelValue[value: string | null]

Released under the MIT License. Character names and artwork belong to their owners.