swatch

Swatch

A colour or picture of one product option, such as a jacket's colour, that the shopper presses to choose it; can be marked unavailable.

States: Default, Hover, Focus, Checked, Disabled

Parts

PartFileDoes
SwatchSwatch.vueLets the user select a colour or material option, shown as a labelled sample.
SwatchRootSwatchRoot.vueGroups the image and fallback of a swatch and shares its shape and size.
SwatchImageSwatchImage.vueShows a picture of the option, such as a material or pattern.
SwatchFallbackSwatchFallback.vueShows the option's colour while its image loads or when there is none.
SwatchLabelSwatchLabel.vueNames the option a swatch stands for.

Anatomy

<Swatch>
  <SwatchRoot>
    <SwatchFallback />
  </SwatchRoot>
  <SwatchLabel />
</Swatch>

Styling

PartRecipe
Swatchswatch
Swatchswatch-strike
Swatchswatch-strike-halo
SwatchImageswatch-image
SwatchFallbackswatch-fallback
SwatchLabelswatch-label

Install

Writes 6 files into components/ui/swatch/. For agents, npx @frontic/ui docs swatch prints this reference as markdown; the MCP server serves the same.

npm packages
@vueuse/core
class-variance-authority
reka-ui

API reference

Swatch Swatch.vue

Lets the user select a colour or material option, shown as a labelled sample.

PropTypeDefault
defaultValuebooleanfalse
modelValuebooleanfalse
disabledbooleanfalse
asChildbooleanfalse
asAsTag | Component—
namestring—
requiredbooleanfalse
classClassValue—
sizeSwatchSize'md'
shapeSwatchShape'default'
hexstring—
labelstring—
labelClassClassValue—
labelPositionSwatchLabelPosition'bottom'
valueAcceptableValue—
unavailablebooleanfalse
unavailableLabelstring'Unavailable'
EventPayload
update:modelValuevalue: boolean
SlotSlot props
label—
Data attributeValues
data-unavailable—
Recipe swatchSets
base: swatch 8 properties
size: xs 2 properties
size: sm 3 properties
size: mddefault 3 properties
size: lg 3 properties
shape: defaultdefault 1 property
shape: pill 1 property
focus-ringshared state 3 properties
disabledshared state 1 property
Recipe swatch-strikeSets
base: swatch-strike 1 property
Recipe swatch-strike-haloSets
base: swatch-strike-halo 1 property

SwatchRoot SwatchRoot.vue

SwatchImage SwatchImage.vue

SwatchFallback SwatchFallback.vue

SwatchLabel SwatchLabel.vue

Example
State