Fields

Text Field

The text field renders a single-line text input in the admin UI and stores its value as a string in Convex. Use it for titles, names, short labels, and any content that fits on one line. The underlying Convex validator is v.string(), wrapped in v.optional() when the field is not required.

Config options

OptionTypeDefaultDescription
requiredbooleanfalseMakes the field required in both the schema and the admin UI.
placeholderstring—Placeholder text shown when the input is empty.
readOnlybooleanfalseRenders the input as disabled.
maxCharactersnumber—Maximum number of characters allowed. Displays a hint below the label and enforces the limit via the native maxlength attribute.
labelstring | (data) => stringAuto-generatedCustom label for the admin UI.
descriptionstring—Help text displayed below the label.
conditionFieldCondition—Conditionally show or hide this field.
sidebarbooleanfalsePlace this field in the document sidebar.
listColumnbooleanfalseShow as a default column in list views.
searchablebooleanfalseIndex this field for full-text search.

Example usage

import { f, defineVextroCollection } from "vextro";

export const products = defineVextroCollection({
  slug: "products",
  label: "Products",
  collectionType: "content",
  tableName: "products",
  fields: {
    name: f.text({
      required: true,
      placeholder: "Product name",
      listColumn: true,
      searchable: true,
    }),
    sku: f.text({
      label: "SKU",
      placeholder: "ABC-12345",
      readOnly: false,
    }),
    subtitle: f.text({
      description: "A short tagline shown below the product name.",
      maxCharacters: 120,
    }),
  },
});

Character limit

When maxCharacters is set, the admin UI displays a "Max N chars" hint below the label and enforces the limit using the native HTML maxlength attribute. This prevents the user from typing beyond the specified length.

tagline: f.text({ maxCharacters: 60 })

Admin behavior

The text field renders as a standard <input type="text"> element. When searchable is enabled, the field value is indexed for collection-level search queries. When listColumn is enabled, the value appears as a column in the collection list view.

Conditional display

nickname: f.text({
  placeholder: "Display name",
  condition: { field: "useNickname", equals: true },
}),

When a condition is set, the field is always optional in the Convex schema regardless of the required setting. The required validation only applies when the field is visible.

Previous
Overview
Next
Textarea