ColorPickerSwatches

Form & Input
stable

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.

Anatomy of OrigamColorPickerSwatchesSchematic of ColorPickerSwatches with 3 internal parts. 1 2 3 origam-color-picker-swatches __swatch (column) __color (tile, 45x18px)
Anatomy of <origam-color-picker-swatches> — 3 parts: scrollable root ①, column wrapper ②, colour tile ③.
1.origam-color-picker-swatches
Root <div> with overflow-y: auto. maxHeight is injected as inline style to cap the scrollable area.
2.origam-color-picker-swatches__swatch
Column wrapper rendered per item in the outer swatches array. 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.

colorHsv
THSVA | null
Current colour in HSVA format. Used to display a checkmark on the active swatch.
disabled
boolean
false
Disables click interaction on all swatches.
swatches
Array<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.
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
height
number | string
maxHeight
number | string
150
Maximum height of the scrollable swatch area in pixels. Defaults to 150.
maxWidth
number | string
minHeight
number | string
minWidth
number | string
width
number | string

API

Emits

Events emitted by this component.

@update:colorHsv
THSVA
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

Keyboard interactions
KeyAction
TabNavigates between interactive swatch tiles.
Enter / SpaceSelects 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

vue

Ecosystem

Family

Components from the same folder that share conventions and often compose together.