Appearance
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>Menu behaviour
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>| Prop | Type | Default | Description |
|---|---|---|---|
menu | boolean | false | Controls picker visibility (v-model:menu) |
menuProps | IMenuProps | undefined | Props forwarded to the underlying OrigamMenu |
closeOnSelect | boolean | false | Closes the picker immediately after colour selection |
openOnClear | boolean | false | Re-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>| Prop | Type | Default | Description |
|---|---|---|---|
openText | string | 'origam.open' | ARIA label when picker is closed |
closeText | string | '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.
| Prop | Type | Default | Description |
|---|---|---|---|
rules | Array<(v: any) => true | string> | undefined | Validation rules. Each function receives the current colour value and must return true (valid) or an error string |
errorMessages | string | Array<string> | undefined | Static error messages displayed unconditionally |
validateOn | TValidateOn | 'input' | When validation runs: 'input', 'blur', 'submit', or 'lazy' |
error | boolean | false | Force the field into error state |
maxErrors | number | string | 1 | Maximum number of simultaneous error messages shown |
Slots
| Slot | Description |
|---|---|
prepend | Content prepended outside the field |
append | Content appended outside the field |
prependInner | Additional content before the colour swatch |
appendInner | Additional content after the text |
floatingLabel | Custom floating label |
label | Custom label |
prefix | Text prefix inside the field |
suffix | Text suffix inside the field |
clear | Custom clear icon |
loader | Custom loader |
colorSelection | Custom rendering of the selected colour value text |
Emits
| Event | Payload | Description |
|---|---|---|
update:modelValue | string | null | Fires when the colour changes |
update:menu | boolean | Fires when the picker opens or closes |
Design tokens
| Token | Description |
|---|---|
--origam-field---padding-start | Overridden to 0 so the swatch bleeds to the edge |
--origam-color-picker-edit__label---font-size | Republished by the typography bridge at open time; falls back to .75rem |
--origam-picker-title---font-size | Republished by the typography bridge when the popup has a title; falls back to .75rem |