Color Swatch
Features
- Supports custom colors
- Provides an accessible label for screen readers
- Provides a color contrast for better visibility
Installation
Install the component from your command line.
$ npm add reka-uiLooking for a complete color picker? Check out the Color Picker example that combines Color Area, Color Slider, Color Field, and Color Swatch components.
Anatomy
Import all parts and piece them together.
<script setup>
import {
ColorSwatch,
} from 'reka-ui'
</script>
<template>
<ColorSwatch color="#ff0000" />
</template>API Reference
ColorSwatch
The main component that displays a color swatch.
| Prop | Default | Type |
|---|---|---|
as | 'div' | AsTag | ComponentThe element or component this component should render as. Can be overwritten by |
asChild | booleanChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | |
color | '' | string | ColorThe color to display in the swatch as a hex string or Color object.
Example: |
label | stringOptional accessible label for the color. If omitted, the color name will be derived from the color value. |
| Slots (default) | Payload |
|---|---|
color | string |
alpha | number |
