Skip to content

Check

A check field is a checkbox that stores true or false, for settings such as "Featured" or "Hide from navigation".

import {Field} from 'alinea'

// The label is shown next to the checkbox
Field.check('Featured')

// With a description, the label becomes a field label above it
Field.check('Navigation', {
  description: 'Hide this page from the menu'
})

Options

  • description: text next to the checkbox. When set, the label is shown above the checkbox as a regular field label.

  • autoFocus: focus the input when the entry opens.

  • The common options help, width, inline, initialValue, required, validate, readOnly, hidden and shared.

Value

A boolean. Without an initialValue, the value stays unset until an editor ticks the box, so compare with true (or use Boolean(value)) rather than checking for false. The same goes for filters: {featured: true} finds featured entries, but {featured: false} and {featured: {isNot: true}} skip entries where the value was never set. Use {featured: {in: [false, null]}} to find everything that isn't featured.

Set initialValue: true for options that should be on by default.