ColorFieldInput
Defined in: packages/core/src/fields/color/types.ts:45
Configuration input for a color() field.
Colour fields store a CSS colour string. format decides which notation the
picker writes — "hex" (default), "rgb", "hsl" or "oklch". With
themeColors the field may instead store a CSS custom-property reference,
var(--primary), which resolves per colour scheme at render time.
Defaults applied by color():
{ type: "color", label: "", // inferred from the field key by defineCollection required: false, // field is optional by default format: "hex", // picker writes #RRGGBB / #RRGGBBAA themeColors: false, // picker shows the custom swatch only admin: { hidden: false, // visible in the admin form readOnly: false, // editable by default position: "main", // placed in the main content column, not the sidebar width: "full", // spans the full form width, not half cellAlignment: "left", // swatch aligned left in the data table column }}Example
Section titled “Example”// Minimal — label inferred from the key ("Brand Color"), stored as hexbrandColor: color()
// Stored as oklch, ready to interpolate straight into a CSS custom propertyprimaryLight: color({ format: "oklch", required: true, defaultValue: "oklch(65.7% 0.179 40.9)" })
// Half-width, and offer the host app's design tokens as a second taboverlayTint: color({ themeColors: true, admin: { width: "half" } })BaseFieldInput for shared properties (label, description, required, admin, index, searchIndex)
Extends
Section titled “Extends”BaseFieldInput<TFieldMeta>
Type Parameters
Section titled “Type Parameters”TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends object = { }
Properties
Section titled “Properties”admin?
Section titled “admin?”
optionaladmin?:FieldAdminConfigInput
Defined in: packages/core/src/fields/baseTypes.ts:209
Admin UI configuration for this field.
Inherited from
Section titled “Inherited from”defaultValue?
Section titled “defaultValue?”
optionaldefaultValue?:string
Defined in: packages/core/src/fields/color/types.ts:51
Pre-filled value shown in the admin form when creating a new document. Does not affect existing database values.
Overrides
Section titled “Overrides”description?
Section titled “description?”
optionaldescription?:string
Defined in: packages/core/src/fields/baseTypes.ts:194
Semantic description of the field. Used in three places:
- Helper text rendered below the field input in the admin form UI.
- As the Zod
.meta({ description })value for form validation. - As the JSDoc comment on the generated document interface property.
To write a separate JSDoc comment, use interfaceDescription in addition.
Inherited from
Section titled “Inherited from”format?
Section titled “format?”
optionalformat?:"hex"|"rgb"|"hsl"|"oklch"
Defined in: packages/core/src/fields/color/types.ts:65
The CSS notation the picker writes.
Validation is deliberately wider than this: every supported notation is
accepted on save, so changing format never invalidates existing
documents. format governs new writes, not stored history.
Pick the notation the front end consumes. A theme collection feeding CSS
custom properties should use "oklch" so values interpolate directly with
no conversion step.
Default Value
Section titled “Default Value”"hex"
index?
Section titled “index?”
optionalindex?:string
Defined in: packages/core/src/fields/baseTypes.ts:220
Create a database index on this field. The string value becomes the index name in Convex.
Example
Section titled “Example”slug: { type: "text", index: "by_slug", required: true }// Generates: .index("by_slug", ["slug"])Inherited from
Section titled “Inherited from”interfaceDescription?
Section titled “interfaceDescription?”
optionalinterfaceDescription?:string
Defined in: packages/core/src/fields/baseTypes.ts:196
The JSDoc comment on the generated document interface property
Inherited from
Section titled “Inherited from”BaseFieldInput.interfaceDescription
label?
Section titled “label?”
optionallabel?:string
Defined in: packages/core/src/fields/baseTypes.ts:185
Display label for the field in the admin form.
Inherited from
Section titled “Inherited from”
optionalmeta?:TFieldMeta
Defined in: packages/core/src/fields/baseTypes.ts:221
Inherited from
Section titled “Inherited from”required?
Section titled “required?”
optionalrequired?:boolean
Defined in: packages/core/src/fields/baseTypes.ts:202
Whether this field is required.
Default: false
Inherited from
Section titled “Inherited from”themeColors?
Section titled “themeColors?”
optionalthemeColors?:boolean
Defined in: packages/core/src/fields/color/types.ts:78
When true, the picker gains a Theme tab listing the CSS custom
properties declared by the host application’s stylesheet, and selecting one
stores a var(--token) reference instead of a literal colour.
The admin panel renders inside the host app, so those tokens are the site’s
own tokens. Leave this false on the fields that define the tokens: a
field whose value is written back out as --primary: var(--primary) is a
custom-property cycle, which CSS discards at computed-value time.
Default Value
Section titled “Default Value”false