ColorPickerSwatches

Form & Input
stable

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.

Anatomy of OrigamColorPickerSwatchesSchematic of ColorPickerSwatches with 3 internal parts. 1 2 3 origam-color-picker-swatches __swatch (column) __color (tile, 45x18px)
Anatomy of <origam-color-picker-swatches> — 3 parts: scrollable root ①, column wrapper ②, colour tile ③.
1.origam-color-picker-swatches
Root <div> with overflow-y: auto. maxHeight is injected as inline style to cap the scrollable area.
2.origam-color-picker-swatches__swatch
Column wrapper rendered per item in the outer swatches array. 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.

colorHsv
THSVA | null
Current colour in HSVA format. Used to display a checkmark on the active swatch.
disabled
boolean
false
Disables click interaction on all swatches.
swatches
Array<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.
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
height
number | string
maxHeight
number | string
150
Maximum height of the scrollable swatch area in pixels. Defaults to 150.
maxWidth
number | string
minHeight
number | string
minWidth
number | string
width
number | string

API

Emits

Événements émis par ce composant.

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

Interactions clavier
ToucheAction
TabNavigates between interactive swatch tiles.
Enter / SpaceSelects 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

vue

Écosystème

Famille

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