ColorPickerSwatches
Scrollable grid of predefined colour swatches. Clicking a swatch emits the selected HSVA colour.
Structure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<origam-color-picker-swatches> — 3 parts: scrollable root ①, column wrapper ②, colour tile ③.- 1.origam-color-picker-swatches
- Root
<div>withoverflow-y: auto.maxHeightis injected as inline style to cap the scrollable area. - 2.origam-color-picker-swatches__swatch
- Column wrapper rendered per item in the outer
swatchesarray.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
Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.
- colorHsvTHSVA | null
- Current colour in HSVA format. Used to display a checkmark on the active swatch.
- disabledbooleanfalse
- Disables click interaction on all swatches.
- swatchesArray<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.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- heightnumber | string
- maxHeightnumber | string150
- Maximum height of the scrollable swatch area in pixels. Defaults to 150.
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string
API
Emits
Événements émis par ce composant.
- @update:colorHsvTHSVA
- Fired when a swatch tile is clicked. Emits the selected colour converted to HSVA.
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.
Personnalisation
Variables CSS
Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.
- Size of individual swatch colour tiles.
- Gap between swatch tiles.
- Border-radius of each swatch tile.
Inclusion
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Interactions clavier
| Touche | Action |
|---|---|
| Tab | Navigates between interactive swatch tiles. |
| Enter / Space | Selects 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.
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 swatches
Écosystème
Famille
Composants du même dossier qui partagent les conventions et se composent souvent ensemble.
ColorPicker
Full-featured HSVA colour picker. Composes canvas, preview, edit and swatches.
ColorPickerCanvas
Gradient canvas where the user drags or keyboard-navigates a cursor to pick saturation and brightness.
ColorPickerPreview
Hue and alpha sliders with a colour preview swatch.
ColorPickerEdit
Inline input fields for HEX/RGB/HSL/HSV editing.