Skip to content

array

array<TCollectionSlug, TFieldKey, TArrayType, TFieldMeta>(options): ArrayField<TCollectionSlug, TArrayType, TFieldMeta>

Defined in: packages/core/src/fields/array/config.ts:62

Creates an array field with all defaults applied.

Array fields store ordered lists of values — strings, numbers, booleans, or nested objects. Items are validated by a nested field definition (items) which supports any VexCMS field type including nested arrays.

Accepts ArrayFieldInput (all optional) and returns ArrayField with all defaults applied.

Defaults applied:

  • label — "" (inferred from the field key by defineCollection); the admin UI uses it as the plural (“Grid Items”) and items.label as the singular (“Grid Item”) — see arrayItemLabel
  • required — false
  • defaultValue — []
  • admin.hidden — false
  • admin.readOnly — false
  • admin.position — "main"
  • admin.width — "100%"
  • admin.cellAlignment — "left"

TCollectionSlug extends string = string

TFieldKey extends string = never

TArrayType extends ArrayType = string

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

ArrayFieldInput<TCollectionSlug, TFieldKey, TArrayType, TFieldMeta>

Array field configuration. All properties are optional.

ArrayField<TCollectionSlug, TArrayType, TFieldMeta>

Resolved array field definition with all defaults applied.

import { array, text, defineCollection } from '@vexcms/core'
posts: defineCollection({
fields: {
// Simple string tags array
tags: array({
items: text(),
}),
// Number array with a min length
scores: array({
items: number(),
min: 1,
}),
// Nested array — array of arrays of numbers
matrix: array({
items: array({ items: number() }),
}),
}
})