Skip to content

OrigamColorPickerField ​

<OrigamColorPickerField> is a text-field that opens an <OrigamColorPicker> in a dropdown menu. The selected colour is displayed as a swatch inside the field prefix.

Basic usage ​

vue
<template>
    <OrigamColorPickerField v-model="color" label="Brand colour" />
</template>

<script setup>
import { ref } from 'vue'
const color = ref(null)
</script>

The picker opens when the user clicks the field. Use close-on-select to close it automatically once a colour is chosen.

vue
<template>
    <OrigamColorPickerField v-model="color" close-on-select />
</template>
PropTypeDefaultDescription
menubooleanfalseControls picker visibility (v-model:menu)
menuPropsIMenuPropsundefinedProps forwarded to the underlying OrigamMenu
closeOnSelectbooleanfalseCloses the picker immediately after colour selection
openOnClearbooleanfalseRe-opens the picker when the field is cleared

Typing a value directly ​

Besides picking a colour from the popover, the field also accepts a value typed directly into the text input — a hex (#ff0, #ff00aa, with or without alpha), a functional notation (rgb(...), hsl(...), …), a named CSS colour, or a var(--…) reference.

modelValue is written the instant the typed text becomes a syntactically complete CSS colour — not on every keystroke and not only on blur. Typing #ff00aa character by character commits progressively (#ff0 alone is already a valid 3-digit shorthand, so it commits; #ff does not, and is silently rejected). A value that never becomes a complete colour is never written to the model — the field simply keeps its last committed value until the input is either completed or cleared. Clearing the field resets the model the same way click:clear already does.

The dropdown follows your own typography ​

The picker is teleported out of the field's DOM subtree so it can escape overflow and stacking contexts. A consequence catches most applications out: CSS you write against the field never reaches the popup. A compact form theme, a scaled container, or a plain rule like

css
.my-form .origam-color-picker-field * { font-size: 13px; }

used to shrink the control and leave the channel labels (R G B A) at their own size — a small field opening a visibly oversized popup.

Inheriting font-size on the teleported surface would not have fixed it either: the labels are sized with var(--origam-color-picker-edit__label---font-size, .75rem), and rem resolves against the document root, not the parent — they would keep the root size whatever the surface inherited.

So OrigamColorPickerField measures the typography that actually won on the field when the popup opens, and republishes it on the teleported surface as the tokens the picker already reads (plus --origam-picker-title---font-size, for a popup title). Nothing to configure: any rule of yours that changes the field's font is picked up, including rules the design system cannot see.

menuProps.contentProps.style still wins, for a popup you want to diverge on purpose:

vue
<template>
  <OrigamColorPickerField
      v-model="color"
      label="Brand colour"
      :menu-props="{ contentProps: { style: { fontSize: '15px' } } }"
  />
</template>

The measurement is taken at open time, so a font that changes while the popup is already open is picked up at the next opening.

Labels and text ​

vue
<template>
    <OrigamColorPickerField
        v-model="color"
        open-text="origam.open"
        close-text="origam.close"
    />
</template>
PropTypeDefaultDescription
openTextstring'origam.open'ARIA label when picker is closed
closeTextstring'origam.close'ARIA label when picker is open

States ​

vue
<template>
    <OrigamColorPickerField v-model="color" disabled />
    <OrigamColorPickerField v-model="color" readonly />
</template>

Validation ​

Pass a rules array to validate the selected colour. Each rule is a function (value) => true | string. The message is rendered by OrigamMessages (.origam-messages) below the field.

vue
<template>
    <OrigamColorPickerField
        v-model="color"
        label="Brand colour"
        :rules="[v => !!v || 'Color required']"
        validate-on="blur"
    />
</template>

The validationValue passed to the underlying OrigamInput is always the current colour value (model.value). When the field is empty (null), validation rules receive null — the falsy check !!v correctly triggers the error message.

PropTypeDefaultDescription
rulesArray<(v: any) => true | string>undefinedValidation rules. Each function receives the current colour value and must return true (valid) or an error string
errorMessagesstring | Array<string>undefinedStatic error messages displayed unconditionally
validateOnTValidateOn'input'When validation runs: 'input', 'blur', 'submit', or 'lazy'
errorbooleanfalseForce the field into error state
maxErrorsnumber | string1Maximum number of simultaneous error messages shown

Slots ​

SlotDescription
prependContent prepended outside the field
appendContent appended outside the field
prependInnerAdditional content before the colour swatch
appendInnerAdditional content after the text
floatingLabelCustom floating label
labelCustom label
prefixText prefix inside the field
suffixText suffix inside the field
clearCustom clear icon
loaderCustom loader
colorSelectionCustom rendering of the selected colour value text

Emits ​

EventPayloadDescription
update:modelValuestring | nullFires when the colour changes
update:menubooleanFires when the picker opens or closes

Design tokens ​

TokenDescription
--origam-field---padding-startOverridden to 0 so the swatch bleeds to the edge
--origam-color-picker-edit__label---font-sizeRepublished by the typography bridge at open time; falls back to .75rem
--origam-picker-title---font-sizeRepublished by the typography bridge when the popup has a title; falls back to .75rem