Skip to content

text

text<TCollectionSlug, TFieldKey, TFieldMeta>(options?): TextField<TCollectionSlug, TFieldMeta>

Defined in: packages/core/src/fields/text/config.ts:52

Creates a text field with all defaults applied.

Text fields store short, single-line string values. Common uses: titles, names, slugs, URLs, email addresses.

Accepts TextFieldInput (all optional) and returns TextField with all defaults applied.

Defaults applied:

  • label — "" (inferred from the field key by defineCollection)
  • required — false
  • admin.hidden — false
  • admin.readOnly — false
  • admin.position — "main"
  • admin.width — "100%"
  • admin.cellAlignment — "left"
  • admin.mask — not set (opt-in; no project-wide default applies unless configured)

TCollectionSlug extends string = string

TFieldKey extends string = never

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

TextFieldInput<TCollectionSlug, TFieldKey, TFieldMeta>

Text field configuration. All properties are optional.

TextField<TCollectionSlug, TFieldMeta>

Resolved text field definition with all defaults applied.

import { text, defineCollection } from '@vexcms/core'
posts: defineCollection({
fields: {
// Minimal — label inferred from key ("Title")
title: text(),
// Required slug with length validation and a database index
slug: text({ required: true, min: 3, max: 100, index: "by_slug" }),
// Author name with a placeholder hint in the admin form
authorName: text({
required: true,
admin: { width: "50%", placeholder: "e.g. Jane Smith" },
}),
}
})