ColorPickerPreview
Hue and alpha sliders with a colour preview swatch and optional eye-dropper button.
Structure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<origam-color-picker-preview> — 4 parts: root flex container ①, preview dot ②, hue slider ③, alpha slider ④ (hidden when hideAlpha).- 1.origam-color-picker-preview
- Root
<div>withdisplay: flex; align-items: center. Has--hide-alphaBEM modifier whenhideAlpha=true. - 2.origam-color-picker-preview__dot
- Circular swatch showing the current colour. Uses a checkerboard background for transparency. 30x30px,
border-radius: 50%. - 3.origam-color-picker-preview__hue
OrigamSliderFieldranging 0–360 for hue. Track background is the full hue gradient. Fill track is hidden.- 4.origam-color-picker-preview__alpha
OrigamSliderFieldranging 0–1 for alpha (step 1/256). Track background is a transparency-to-current-colour gradient. Conditionally rendered viav-if="!hideAlpha".
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 }. Drives the hue slider position and the preview swatch fill.
- disabledbooleanfalse
- Disables slider interaction. Passed through to both SliderField children.
- hideAlphabooleanfalse
- Hides the alpha slider. Applied as a BEM modifier --hide-alpha on the root element.
- ariaLabelstring
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- heightnumber | string
- Override height of the preview strip. Accepts a CSS length or a number (px).
- maxHeightnumber | string
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string
- Override width of the preview strip.
API
Emits
Événements émis par ce composant.
- @update:colorHsvTHSVA
- Fired when the user moves the hue or alpha slider, or picks a colour with the eye-dropper. Emits the updated HSVA 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.
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.
- Width of the preview dot swatch.
- Height of the preview dot swatch.
- Border-radius of the preview dot swatch.
- CSS custom property injected at runtime with the current hue as a CSS colour. Used as the end stop of the alpha gradient track.
Inclusion
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Interactions clavier
| Touche | Action |
|---|---|
| Tab | Moves focus between the hue slider, alpha slider, and eye-dropper button. |
| Arrow Left / Right | Adjusts the focused slider (hue or alpha) by one step. |
Notes
- Each SliderField is a native range-like widget with aria-valuemin, aria-valuemax and aria-valuenow. Keyboard navigation is handled by OrigamSliderField.
- The eye-dropper button is only rendered when window.EyeDropper is available (Chromium 95+). On unsupported browsers the slot is absent.
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 preview
Without alpha slider
É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.
ColorPickerEdit
Inline input fields for HEX/RGB/HSL/HSV editing.
ColorPickerSwatches
Grid of predefined colour swatches.