ColorPickerField
Text field input that opens a ColorPicker in a dropdown menu. The selected colour is displayed as a swatch inside the field prefix.
Preview
Rendering the live preview…
defaultRendering the live preview…
outlinedRendering the live preview…
disabledStructure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<origam-color-picker-field> — 4 visual parts.- 1.origam-color-picker-field
- Root element — extends OrigamTextField with a colour swatch prefix.
- 2.origam-color-picker-field__swatch
- Small coloured square inside the input prefix. Shows the current selected colour. Clicking opens the picker.
- 3.origam-text-field__input
- Editable text input showing the colour value (hex string). Clearing triggers openOnClear if enabled.
- 4.origam-color-picker-field__chevron
- Append icon indicating the dropdown can be opened.
API
Props
All props accepted by this component, with their type, default value and description.
- menuboolean
- Controls whether the colour picker popover is open.
- menuPropsIMenuProps
- Props forwarded to the inner OrigamMenu component.
- openOnClearboolean
- Re-opens the picker dropdown when the field value is cleared.
- closeTextstring
- Accessible label for the close action inside the picker popover.
- openTextstring
- Accessible label for the open action inside the picker popover.
- closeOnSelectboolean
- Closes the picker popover automatically when a colour is selected.
- autofocusboolean
- counterboolean | number | string
- counterValuenumber | ((e: any) => number)
- placeholderstring
- Placeholder text shown when the field is empty.
- persistentPlaceholderboolean
- persistentCounterboolean
- rolestring
- typeTTextFieldType
- modelModifiersstring | boolean
- maskTMask
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- colorTColor
- Intent or custom colour applied to the active/focused field state.
- densityTDensity'default'
- Adjusts the vertical padding density of the field.
- centerAffixboolean
- dirtyboolean
- disabledbooleanfalse
- Disables the field and prevents opening the picker.
- errorstring | boolean
- inlineboolean
- labelstring
- Floating label displayed above the field.
- prefixstring
- suffixstring
- persistentClearboolean
- singleLineboolean
- requiredboolean
- loadingTControlLoadingValue
- tagstring
- loadingTextstring
- bgColorTColor
- appendInnerAvatarstring
- appendInnerIconTIcon
- prependInnerAvatarstring
- prependInnerIconTIcon
- clearIconTIcon
- clearablebooleanfalse
- Displays a clear icon to reset the selected colour.
- prependInnerAriaLabelstring
- appendInnerAriaLabelstring
- borderboolean | number | string | TDirectionBoth | Array<TDirectionBoth>false
- Applies an explicit border to the field.
- borderTopboolean | number | string
- borderLeftboolean | number | string
- borderBottomboolean | number | string
- borderRightboolean | number | string
- borderBlockboolean | number | string
- borderInlineboolean | number | string
- borderInlineStartboolean | number | string
- borderInlineEndboolean | number | string
- borderBlockStartboolean | number | string
- borderBlockEndboolean | number | string
- borderColorstring
- borderStylestring
- borderTopColorTColor
- borderRightColorTColor
- borderBottomColorTColor
- borderLeftColorTColor
- borderInlineStartColorTColor
- borderInlineEndColorTColor
- borderBlockStartColorTColor
- borderBlockEndColorTColor
- focusedboolean
- textstring
- floatingboolean
- namestring
- marginboolean | number | string
- marginTopboolean | number | string
- marginLeftboolean | number | string
- marginBottomboolean | number | string
- marginRightboolean | number | string
- marginBlockboolean | number | string
- marginInlineboolean | number | string
- marginInlineStartboolean | number | string
- marginInlineEndboolean | number | string
- marginBlockStartboolean | number | string
- marginBlockEndboolean | number | string
- paddingboolean | number | string
- paddingTopboolean | number | string
- paddingLeftboolean | number | string
- paddingBottomboolean | number | string
- paddingRightboolean | number | string
- paddingBlockboolean | number | string
- paddingInlineboolean | number | string
- paddingInlineStartboolean | number | string
- paddingInlineEndboolean | number | string
- paddingBlockStartboolean | number | string
- paddingBlockEndboolean | number | string
- roundedboolean | number | string | TRounded | null | undefined
- Border-radius token for the field wrapper.
- roundedTopRightboolean | number | string
- roundedTopLeftboolean | number | string
- roundedBottomLeftboolean | number | string
- roundedBottomRightboolean | number | string
- roundedStartStartboolean | number | string
- roundedStartEndboolean | number | string
- roundedEndStartboolean | number | string
- roundedEndEndboolean | number | string
- fontSizeTFontSize
- fontWeightTFontWeight
- lineHeightTLineHeight
- letterSpacingTLetterSpacing
- activeboolean | IStateEffectConfig
- activeClassstring
- variantTVariantInput'outlined'
- Visual style variant for the field wrapper.
- elevationTElevation
- sizeTSize | number
- hideDetailsboolean | string
- hideSpinButtonsboolean
- hintstring
- persistentHintboolean
- messagesArray<string> | string
- heightnumber | string
- maxHeightnumber | string
- maxWidthnumber | string
- minHeightnumber | string
- minWidthnumber | string
- widthnumber | string
- directionTDirection
- errorMessagesArray<string> | string
- maxErrorsnumber | string
- readonlybooleanfalse
- Makes the field non-interactive without visually disabling it.
- rulesArray<any>
- modelValueany
- Current colour value (v-model). CSS colour string, e.g. "#ff0080" or "hsl(320, 100%, 50%)".
- validateOnTValidateOn
- validationValueany
- appendAvatarstring
- appendIconTIcon
- prependAvatarstring
- prependIconTIcon
- prependAriaLabelstring
- appendAriaLabelstring
- transitionboolean | string | TTransitionProps
API
Slots
Content slots exposed by this component.
- #colorSelection
- #label
- Custom label content. Overrides the label prop.
- #clear
- #prependInner
- Content placed inside the field before the input (swatch area).
- #appendInner
- Content placed inside the field after the input.
- #loader
- Custom loader shown inside the field when loading is true.
- #floatingLabel
- #prefix
- #suffix
- #prepend
- Content placed before the field (outside the field wrapper).
- #append
- Content placed after the field (outside the field wrapper).
API
Emits
Events emitted by this component.
- @update:modelValueTColor
- Fired when the selected colour changes. Payload is the new colour string.
- @update:menuboolean
- Fired when the picker popover opens or closes.
- @click:clearMouseEvent
- Fired when the user clicks the clear icon.
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 OrigamTextField.
- Ref<boolean>
- True while the field is focused.
- Ref<boolean>
- Controls the picker popover open state programmatically.
- 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.
Customisation
CSS variables
CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.
- Minimum width of the field.
- Width of the colour swatch inside the input.
- Height of the colour swatch.
- Border radius of the colour swatch.
- Colour of the dropdown chevron icon.
- Colour of the chevron icon on hover.
Inclusion
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
ARIA roles
Keyboard interactions
| Key | Action |
|---|---|
| Enter / Space | Opens the colour picker popover. |
| Escape | Closes the colour picker popover without applying changes. |
| Tab | Moves focus into or out of the picker panel when open. |
Notes
- The field behaves as a combobox: aria-haspopup="dialog" and aria-expanded reflect the popover open state.
- The colour swatch is decorative (aria-hidden="true"). The accessible value is provided by the text input which holds the hex string.
Foundation
Design tokens
Excerpt from this component's token declarations — the --origam-<component>---<property> variables, declared in its hand-maintained token sheet with no build step.
- dimension200px
- Minimum field width.
- dimension24px
- Swatch width.
- dimension24px
- Swatch height.
- dimensionvar(--origam-radius---sm)
- Swatch corner radius.
- colorvar(--origam-color__text---secondary)
- Chevron icon colour.
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.
Basic usage
Close on select