FieldsConditional fields

Conditional fields

Hide a field while another field has a certain value, so editors see only the fields that apply.

View as Markdown

The condition

Every field and setting takes .hidden(condition), and f.when(path) builds the condition:

f.when(path).is(value)Hidden while the field at path equals value.
f.when(path).isNot(value)Hidden while it differs.
f.when(path).in([a, b])Hidden while it is one of the listed values.
f.when(path).isEmpty()Hidden while it is empty: unset, an empty string or list, or an image with no asset.
f.when(path).isNotEmpty()Hidden while it has a value.

A hidden field leaves the form and is skipped at publish, so a required field that is hidden is not required. Its stored value stays, and comes back when the condition stops holding.

Paths

A bare path names a sibling: a field at the same level as the one being hidden. Inside an object or a list item, that is the item's own fields. A path prefixed with fields. or settings. names a top-level key of that group from anywhere.

A link that is either a page on the site or an external address:

The schema goes in src/components/sections/Banner.schema.ts, written as in the Next.js tab. Its view, src/sections/banner.astro, picks the link the same way, through safeHref since an editor typed it: href={safeHref(cta.kind === "external" ? cta.url : cta.path)}.

Inside cta, kind is a sibling of path and url, so the bare path reads it. The background setting reads settings.tone with the prefix. A condition that names a field the schema does not have fails at startup, not in the form.

The view still receives hidden fields as typed, so the sample above branches on kind itself rather than trusting that one of the two links is empty.

Next, the Pages group covers what editors do with pages once the shapes exist.

Edit this page on GitHubLast updated 6 Oct 2026