ColorPickerSwatches
Scrollable grid of predefined colour swatches. Clicking a swatch emits the selected HSVA colour.
Structure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<origam-color-picker-swatches> — 3 parts: scrollable root ①, column wrapper ②, colour tile ③.- 1.origam-color-picker-swatches
- Root
<div>withoverflow-y: auto.maxHeightis injected as inline style to cap the scrollable area. - 2.origam-color-picker-swatches__swatch
- Column wrapper rendered per item in the outer
swatchesarray.display: flex; flex-direction: column. - 3.origam-color-picker-swatches__color
- Individual swatch tile (45x18px). Has a checkerboard underlay for transparency. Renders a checkmark icon (
OrigamIcon) when the tile matches the current colour.
API
Props
All props accepted by this component, with their type, default value and description.
- colorHsvTHSVA | null
- Current colour in HSVA format. Used to display a checkmark on the active swatch.
- disabledbooleanfalse
- Disables click interaction on all swatches.
- swatchesArray<Array<TColorType>>
- Array of colour columns. Each column is an array of TColorType values (hex string, RGB object, etc.). Rendered as a grid of swatch tiles.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- heightnumber | string
- maxHeightnumber | string150
- Maximum height of the scrollable swatch area in pixels. Defaults to 150.
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string
API
Emits
Events emitted by this component.
- @update:colorHsvTHSVA
- Fired when a swatch tile is clicked. Emits the selected colour converted to HSVA.
API
Exposed members
Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.
- <T extends object>(props: T, exclude?: string[]) => Partial<T>
- Utility to forward a filtered subset of props to a child component.
- Ref<string>
- Reactive CSS string generated by useStyle.
- string
- Unique style-sheet ID for this instance.
- () => void
- Injects the computed style sheet into the document.
- () => void
- Removes the injected style sheet.
- Ref<boolean>
- True once the style sheet has been injected into the DOM.
Customisation
CSS variables
CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.
- Size of individual swatch colour tiles.
- Gap between swatch tiles.
- Border-radius of each swatch tile.
Inclusion
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Navigates between interactive swatch tiles. |
| Enter / Space | Selects the focused swatch and emits update:colorHsv. |
Notes
- The checkmark icon colour is automatically chosen for contrast: white on dark colours and black on light colours (getContrast utility, threshold >2).
- Swatch tiles do not currently expose aria-label with the colour value. It is recommended to add aria-label with the hex value when using the component standalone.
Interactive
Playground
Edit props live and see the component update in real time. The generated code snippet updates as you change values.
Rendering the live preview…
Usage
Examples
Ready-to-paste code snippets for your templates.
Standalone swatches
Ecosystem
Family
Components from the same folder that share conventions and often compose together.
ColorPicker
Full-featured HSVA colour picker. Composes canvas, preview, edit and swatches.
ColorPickerCanvas
Gradient canvas where the user drags or keyboard-navigates a cursor to pick saturation and brightness.
ColorPickerPreview
Hue and alpha sliders with a colour preview swatch.
ColorPickerEdit
Inline input fields for HEX/RGB/HSL/HSV editing.