Skip to content

select

select<TCollectionSlug, TFieldKey, TFieldMeta>(options?): SelectField<TCollectionSlug, TFieldMeta>

Defined in: packages/core/src/fields/select/config.ts:63

Creates a select field with all defaults applied.

Select fields store an array of chosen option values — suitable for status labels, categories, tags, or any enumerable choice set. Set hasMany: false to restrict to a single selection.

Accepts SelectFieldInput (all optional) and returns SelectField with all defaults applied.

Defaults applied:

  • label — "" (inferred from the field key by defineCollection)
  • required — false
  • defaultValue — []
  • options — []
  • hasMany — 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

SelectFieldInput<TCollectionSlug, TFieldKey, TFieldMeta>

Select field configuration. All properties are optional.

SelectField<TCollectionSlug, TFieldMeta>

Resolved select field definition with all defaults applied.

import { select, defineCollection } from '@vexcms/core'
posts: defineCollection({
fields: {
// Single-select status field
tier: select({
required: true,
options: [
{ label: "Free", value: "free" },
{ label: "Pro", value: "pro" },
],
}),
// Multi-select tag field
tags: select({
hasMany: true,
options: [
{ label: "News", value: "news" },
{ label: "Tutorial", value: "tutorial" },
{ label: "Release", value: "release" },
],
}),
}
})