Layout Fields

Collapsible

The f.collapsible() layout field wraps fields in a togglable section with a label. Unlike f.group(), collapsible sections do not create nested objects -- all fields are flattened to the parent level.

Basic usage

import { f, defineVextroCollection } from "vextro";

export const pages = defineVextroCollection({
  slug: "pages",
  label: "Pages",
  collectionType: "content",
  tableName: "pages",
  fields: {
    title: f.text({ required: true }),
    body: f.richText(),
    advanced: f.collapsible({
      label: "Advanced Options",
      collapsed: true,
      fields: {
        cacheControl: f.text({ placeholder: "max-age=3600" }),
        customHeaders: f.json(),
      },
    }),
  },
});

Options

OptionTypeDefaultDescription
labelstringrequiredHeader text for the section.
descriptionstring--Text shown below the label.
fieldsRecord<string, VextroFieldInput>requiredFields inside the section.
collapsedbooleanfalseWhether the section starts collapsed.
conditionFieldCondition--Condition for showing the section.

Conditional collapsible

Show the section only when a condition is met:

externalSettings: f.collapsible({
  label: "External Link Settings",
  condition: { field: "linkType", equals: "external" },
  fields: {
    openInNewTab: f.checkbox(),
    nofollow: f.checkbox(),
  },
}),

Collapsible vs Group

Featuref.collapsible()f.group()
Data storageFlat (parent level)Nested object
Creates object keyNoYes
Collapsible UIAlwaysOptional (collapsible: true)
Use caseVisual grouping onlyLogical data nesting

Use f.collapsible() when you want to tidy the editor without changing document shape. Use f.group() when fields logically belong as a nested object.

Previous
Row
Next
Section