ColorPickerCanvas
Gradient canvas where the user drags or keyboard-navigates a cursor to pick saturation and brightness from the HSV colour space.
Structure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<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
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et 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
Événements émis par ce composant.
- @update:colorHsvTHSVA
- Fired on pointer drag or keyboard navigation. Emits the updated HSVA colour object.
API
Membres exposés
Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.
- <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
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Rôles ARIA
Interactions clavier
| Touche | 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".
Interactif
Playground
Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.
Rendu de l’aperçu en cours…
Usage
Exemples
Extraits de code prêts à coller dans vos templates.
Standalone canvas
Écosystème
Famille
Composants du même dossier qui partagent les conventions et se composent souvent ensemble.