Skip to content

checkbox

checkbox<TCollectionSlug, TFieldKey, TFieldMeta>(options?): CheckboxField<TCollectionSlug, TFieldMeta>

Defined in: packages/core/src/fields/checkbox/config.ts:49

Creates a checkbox field with all defaults applied.

Checkbox fields store boolean values — feature flags, opt-in toggles, published states, visibility flags, and similar on/off settings.

Accepts CheckboxFieldInput (all optional) and returns CheckboxField with all defaults applied.

Defaults applied:

  • label — "" (inferred from the field key by defineCollection)
  • required — false
  • defaultValue — false
  • admin.hidden — false
  • admin.readOnly — false
  • admin.position — "main"
  • admin.width — "100%"
  • admin.cellAlignment — "left"

TCollectionSlug extends string = string

TFieldKey extends string = never

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

CheckboxFieldInput<TCollectionSlug, TFieldKey, TFieldMeta>

Checkbox field configuration. All properties are optional.

CheckboxField<TCollectionSlug, TFieldMeta>

Resolved checkbox field definition with all defaults applied.

import { checkbox, defineCollection } from '@vexcms/core'
posts: defineCollection({
fields: {
// Minimal — label inferred from key ("Published")
published: checkbox(),
// Required field, checked by default when creating a new document
featured: checkbox({ defaultValue: true, admin: { width: "50%" } }),
// Indexed flag for fast admin queries
archived: checkbox({ index: "by_archived" }),
}
})