Skip to content

text

text<TFieldMeta>(options?): TextField<TFieldMeta>

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

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)
  • requiredfalse
  • admin.hiddenfalse
  • admin.readOnlyfalse
  • admin.position"main"
  • admin.width"full"
  • admin.cellAlignment"left"

TFieldMeta extends BaseFieldMeta = BaseFieldMeta

TextFieldInput<TFieldMeta>

Text field configuration. All properties are optional.

TextField<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: { value: 3 }, max: { value: 100 }, index: "by_slug" }),
// Author name with a placeholder hint in the admin form
authorName: text({
required: true,
admin: { width: "half", placeholder: "e.g. Jane Smith" },
}),
}
})