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 bydefineCollection)required—falseadmin.hidden—falseadmin.readOnly—falseadmin.position—"main"admin.width—"100%"admin.cellAlignment—"left"admin.mask— not set (opt-in; no project-wide default applies unless configured)
Type Parameters
Section titled “Type Parameters”TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends string = string
TFieldKey
Section titled “TFieldKey”TFieldKey extends string = never
TFieldMeta
Section titled “TFieldMeta”TFieldMeta extends BaseFieldMeta = BaseFieldMeta
Parameters
Section titled “Parameters”options?
Section titled “options?”TextFieldInput<TCollectionSlug, TFieldKey, TFieldMeta>
Text field configuration. All properties are optional.
Returns
Section titled “Returns”TextField<TCollectionSlug, TFieldMeta>
Resolved text field definition with all defaults applied.
Example
Section titled “Example”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" }, }), }})- TextFieldInput for the full input type
- TextField for the resolved output type