Return to Sky UI homepage
import { Swatch } from '@sky-uk/ui-core';

Props

PropTypeDefaultDescription
$sizestringregularSets the size of the swatch. Options are 'mini', 'small', and 'regular'.
$colorwaystringblackSets the background color of the swatch. Accepts any valid CSS color value.
$gradientstring-Sets the background gradient of the swatch. Accepts any valid CSS gradient value.
$imagestring-Sets the background image of the swatch. Accepts any valid image URL.
$outlinebooleanfalseAn outline that provides contrast against the background the Swatch is used on.
$selectedbooleanfalseAdds a selected state to the swatch, indicating it is currently selected.
$unavailablebooleanfalseAdds a strikethrough to the swatch, indicating it is not selectable.

Sizes

Styles

  • Set a background colour using $colorway which takes any valid css background-color value.
  • Apply an image using $image as an image path. Optionally use a transparent png with $colorway to overlay a texture. You can also use $gradient separately or with $colorway.
  • Add an outline to the swatch using $outline. This provides a contrast against the background the swatch is used on, ensuring it is visible even on similar background colors.
  • Use the $selected prop to indicate the swatch is currently selected, while $unavailable adds a strikethrough to show it is not selectable. The $unavailable prop takes precedence over $selected.

Selectable

Add interaction cues by providing an href or onClick with relevant props.

System Modifiers

This component also supports the props applied using the following system modifiers: