color
color<
TFieldMeta>(options?):ColorField<TFieldMeta>
Defined in: packages/core/src/fields/color/config.ts:51
Creates a colour field with all defaults applied.
Colour fields store a CSS colour string and render a swatch picker in the admin form. Common uses: theme palettes, per-document accent colours, block background overrides.
Accepts ColorFieldInput (all optional) and returns ColorField with all defaults applied.
Defaults applied:
label—""(inferred from the field key bydefineCollection)required—falsedefaultValue—""format—"hex"themeColors—falseadmin.hidden—falseadmin.readOnly—falseadmin.position—"main"admin.width—"full"admin.cellAlignment—"left"
Type Parameters
Section titled “Type Parameters”TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends BaseFieldMeta = BaseFieldMeta
Parameters
Section titled “Parameters”options?
Section titled “options?”ColorFieldInput<TFieldMeta>
Colour field configuration. All properties are optional.
Returns
Section titled “Returns”ColorField<TFieldMeta>
Resolved colour field definition with all defaults applied.
Example
Section titled “Example”import { color, defineCollection } from '@vexcms/core'
themes: defineCollection({ fields: { // Minimal — label inferred from key ("Brand Color"), stored as hex brandColor: color(),
// Stored as oklch so the front end can interpolate it directly primaryLight: color({ format: "oklch", required: true }),
// Offer the host app's design tokens as a second picker tab overlayTint: color({ themeColors: true, admin: { width: "half" } }), }})- ColorFieldInput for the full input type
- ColorField for the resolved output type