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

Anatomie

Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.

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

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et 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

Événements émis par ce composant.

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

application

Interactions clavier

Interactions clavier
ToucheAction
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".

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

vue

Écosystème

Famille

Composants du même dossier qui partagent les conventions et se composent souvent ensemble.