Show navigationHide navigation
Boolean
Yes / No toggle rendered as radio buttons. Use for feature flags, visibility toggles, and on/off switches.
Usage#
typescriptfeatured: { label: 'Featured', format: 'boolean' },
Options#
| Option | Type | Default | Description |
|---|---|---|---|
defaultBoolean | boolean | — | Default value for new entries |
booleanLabels | { true: string; false: string } | { true: 'Yes', false: 'No' } | Custom labels for radio buttons |
hint | string | — | Helper text below the field |
Boolean fields always have a value ("true" or "false") — they are never empty or null.
Example: Featured articles#
Schema — mark blog posts as featured to highlight them on the homepage:
typescript// cms/octocms.config.ts post: { label: 'Post', hasMany: true, fields: { title: { label: 'Title', format: 'string', entryTitle: true, required: true }, featured: { label: 'Featured', format: 'boolean', defaultBoolean: false, booleanLabels: { true: 'Featured', false: 'Not featured' }, hint: 'Featured posts appear on the homepage hero section.', }, body: { label: 'Body', format: 'markdown' }, }, },
Query + render:
tsx// src/app/page.tsx import { query } from 'cms/__generated__/query'; export default async function HomePage() { const featured = await query('post') .filter((p) => p.fields.featured === 'true') .sort('publishedAt', 'desc') .limit(3) .toArray(); return ( <section> <h2>Featured Posts</h2> {featured.map((post) => ( <article key={post.sys.id}> <h3>{post.fields.title}</h3> </article> ))} </section> ); }
Storage#
Stored as the string "true" or "false" in the entry JSON (not a native boolean):
json{ "featured": "true" }
Query result#
Returned as a string — "true" or "false". Compare with === 'true' in filters.