Layout Fields

Section

The f.section() field renders a heading and optional description as a visual divider. It stores no data. All fields following a section -- until the next section -- are visually grouped under that heading.

Basic usage

import { f, defineVextroCollection } from "vextro";

export const products = defineVextroCollection({
  slug: "products",
  label: "Products",
  collectionType: "content",
  tableName: "products",
  fields: {
    _contentSection: f.section({ label: "Content" }),
    name: f.text({ required: true }),
    description: f.richText(),

    _pricingSection: f.section({
      label: "Pricing",
      description: "Set the base price and tax configuration.",
    }),
    price: f.number({ required: true, min: 0 }),
    taxRate: f.number({ step: 0.01 }),

    _advancedSection: f.section({ label: "Advanced", collapsed: true }),
    metadata: f.json(),
  },
});

Section keys are typically prefixed with _ to signal they are not data fields.

Options

OptionTypeDefaultDescription
labelstringrequiredHeading text for the section.
descriptionstring--Text shown below the heading.
iconstring--Icon name or SVG string next to the label.
collapsiblebooleantrueWhether the section can be collapsed.
collapsedbooleanfalseWhether the section starts collapsed.
conditionFieldCondition--Condition for showing the section header.

Conditional sections

A condition on a section hides only the heading. Apply the same condition to the fields beneath if you want them hidden as well:

_seoSection: f.section({
  label: "SEO Settings",
  condition: { field: "showSeo", equals: true },
}),
metaTitle: f.text({ condition: { field: "showSeo", equals: true } }),
metaDescription: f.textarea({ condition: { field: "showSeo", equals: true } }),

Section vs Collapsible

Featuref.section()f.collapsible()
Groups fieldsImplicitly (until next section)Explicitly (via fields option)
Contains its own fieldsNoYes
Data storageNone (UI-only)Flat (parent level)

Use f.section() for lightweight visual dividers. Use f.collapsible() when you need explicit control over which fields belong to the group.

Previous
Collapsible