Skip to content

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 by defineCollection)
  • requiredfalse
  • defaultValue""
  • format"hex"
  • themeColorsfalse
  • admin.hiddenfalse
  • admin.readOnlyfalse
  • admin.position"main"
  • admin.width"full"
  • admin.cellAlignment"left"

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

ColorFieldInput<TFieldMeta>

Colour field configuration. All properties are optional.

ColorField<TFieldMeta>

Resolved colour field definition with all defaults applied.

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" } }),
}
})