Calm motion: animations on this site only fade, with no movement
Variant picker
The options of a product, with sold-out values crossed out
Lets a person choose the size, the color, and other options of a product. A color shows as a swatch, and other values show as buttons. For colors with no product, use the color swatches.
Basic
Chosen: {"color":"black","size":"m"}
optionsis a list of options. Each option has akey, aname, and a list ofvalues. Each value has avalueand alabel. A value with acolorshows as a swatch, and a value withsoldOutis crossed out and cannot be chosen.v-modelis an object with the chosen value of each option by key, such as{ color: "black", size: "m" }. A pick changes one key and keeps the others.- The name of the chosen value shows after the name of the option. The chosen value has a thick frame in the text color, so it shows on any swatch.
- Each option is a group of native radio buttons, so the arrow keys move in the group. A swatch has its name for screen readers and as a tooltip. A sold-out value says "sold out". Change the words with
labelsor a label pack:soldOut.
Usage
ts
import { BlessVariantPicker } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
options* | BlessVariantOption[] | — | |
labels | Partial<{ soldOut: string; }> | — | |
modelValue | Record<string, string> | {} | the chosen value of each option, by key |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: Record<string, string>] |