Swatch - React
import { Swatch } from '@sky-uk/ui-core';
Props
Prop | Type | Default | Description |
---|---|---|---|
$size | string | regular | Sets the size of the swatch. Options are 'mini', 'small', and 'regular'. |
$colorway | string | black | Sets the background color of the swatch. Accepts any valid CSS color value. |
$gradient | string | - | Sets the background gradient of the swatch. Accepts any valid CSS gradient value. |
$image | string | - | Sets the background image of the swatch. Accepts any valid image URL. |
$outline | boolean | false | An outline that provides contrast against the background the Swatch is used on. |
$selected | boolean | false | Adds a selected state to the swatch, indicating it is currently selected. |
$unavailable | boolean | false | Adds a strikethrough to the swatch, indicating it is not selectable. |
Sizes
Styles
- Set a background colour using
$colorway
which takes any valid cssbackground-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: