ColorPickerPreview
Hue and alpha sliders with a colour preview swatch and optional eye-dropper button.
Structure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<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
All props accepted by this component, with their type, default value and 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
Events emitted by this component.
- @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
Exposed members
Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.
- <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.
Customisation
CSS variables
CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.
- 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
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
Keyboard interactions
| Key | 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.
Interactive
Playground
Edit props live and see the component update in real time. The generated code snippet updates as you change values.
Rendering the live preview…
Usage
Examples
Ready-to-paste code snippets for your templates.
Standalone preview
Without alpha slider
Ecosystem
Family
Components from the same folder that share conventions and often compose together.
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.