ColorPickerCanvas

Form & Input
stable

Gradient canvas where the user drags or keyboard-navigates a cursor to pick saturation and brightness from the HSV colour space.

Structure

Anatomy

Visual breakdown of the component's internal structure with BEM class call-outs.

Anatomy of OrigamColorPickerCanvasSchematic of ColorPickerCanvas with 3 internal parts. 1 2 3 origam-color-picker-canvas __dot (draggable cursor) canvas (aria-hidden)
Anatomy of <origam-color-picker-canvas> — 3 parts. The gradient is drawn on a <canvas> element; the dot follows pointer/keyboard.
1.origam-color-picker-canvas
Root <div> with role="application", tabindex="0", keyboard and pointer listeners. Observed by useResizeObserver to keep the canvas dimensions in sync.
2.origam-color-picker-canvas__dot
Absolute circle that follows the current saturation/value position. Has --disabled modifier when disabled.
3canvas (internal)
Native <canvas> element with aria-hidden="true". The saturation/value gradient is painted via Canvas 2D API.

API

Props

All props accepted by this component, with their type, default value and description.

colorHsv
THSVA | null
Current colour in HSVA format { h, s, v, a }. The canvas re-renders the gradient when hue changes.
disabled
boolean
false
Disables pointer and keyboard interaction. The dot renders with reduced opacity.
dotSize
string | number
Size of the draggable dot cursor in pixels.
ariaLabel
string
Overrides the default localised aria-label on the canvas element.
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
height
number | string
150
Canvas height in pixels. Defaults to 150.
maxHeight
number | string
maxWidth
number | string
minHeight
number | string
minWidth
number | string
width
number | string
'100%'
Canvas width. Defaults to 100% of the container.

API

Emits

Events emitted by this component.

@update:colorHsv
THSVA
Fired on pointer drag or keyboard navigation. Emits the updated HSVA colour object.

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.

Inclusion

Accessibility

ARIA roles, keyboard navigation and focus management. Sourced from the real component template.

ARIA roles

application

Keyboard interactions

Keyboard interactions
KeyAction
Arrow keysMoves the colour cursor by ±1% saturation (horizontal) or value (vertical). Hold Shift for ±5% steps.
Home / EndHome sets saturation to 0 (fully desaturated). End sets saturation to 1 (fully saturated).
Page Up / Page DownPage Up sets value to 1 (fully bright). Page Down sets value to 0 (black).

Notes

  • The root element uses role="application" and aria-valuetext exposing the current saturation and brightness percentages. The underlying canvas element has aria-hidden="true".
  • Focus-visible outline (2px solid --origam-color__border---focus) is applied on :focus-visible. The component is focusable via tabindex="0".

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 canvas

vue

Ecosystem

Family

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