ColorPickerCanvas
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.
<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>withrole="application",tabindex="0", keyboard and pointer listeners. Observed byuseResizeObserverto keep the canvas dimensions in sync. - 2.origam-color-picker-canvas__dot
- Absolute circle that follows the current saturation/value position. Has
--disabledmodifier when disabled. - 3canvas (internal)
- Native
<canvas>element witharia-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.
- colorHsvTHSVA | null
- Current colour in HSVA format { h, s, v, a }. The canvas re-renders the gradient when hue changes.
- disabledbooleanfalse
- Disables pointer and keyboard interaction. The dot renders with reduced opacity.
- dotSizestring | number
- Size of the draggable dot cursor in pixels.
- ariaLabelstring
- Overrides the default localised aria-label on the canvas element.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- heightnumber | string150
- Canvas height in pixels. Defaults to 150.
- maxHeightnumber | string
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string'100%'
- Canvas width. Defaults to 100% of the container.
API
Emits
Events emitted by this component.
- @update:colorHsvTHSVA
- 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
Keyboard interactions
| Key | Action |
|---|---|
| Arrow keys | Moves the colour cursor by ±1% saturation (horizontal) or value (vertical). Hold Shift for ±5% steps. |
| Home / End | Home sets saturation to 0 (fully desaturated). End sets saturation to 1 (fully saturated). |
| Page Up / Page Down | Page 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
Ecosystem
Family
Components from the same folder that share conventions and often compose together.