Boolean Field
Switch/checkbox input for true/false values
The Boolean Field component provides a switch or checkbox input for collecting true/false boolean values.
Basic Usage
Basic Switch
With Description
With Description
Default Value
Pre Checked
Field Schema
A boolean field is authored as BooleanFieldMetadata (@object-ui/types), which is
the source of truth for the key set. It adds nothing of its own to
BaseFieldMetadata beyond the discriminant — a checkbox needs no extra configuration.
import type { BooleanFieldMetadata } from '@object-ui/types';
const isActive: BooleanFieldMetadata = {
type: 'boolean',
name: 'is_active',
label: 'Active',
description: 'Inactive records stay searchable but are excluded from lists.',
required: false,
defaultValue: true,
};The value being edited, and the className / disabled a host supplies, are not
metadata keys — they are runtime widget props. See Field Widget Props.
Read-only Display
In a read-only row (a readonly field in a generated form, or a detail body), the widget draws
a real true as "Yes" and a real false as "No". Only a real boolean is a value of a boolean
field. @objectstack/spec declares the runtime value of boolean / toggle as a bare JS
boolean on the wire; the SQL 0/1 repair and the 'true' / 'false' spellings belong to
the producer boundaries (driver read-coercion, CSV import), never to the widget. So null,
undefined, [], {}, 0, 1, '', 'true' and 'false' all render the shared
EmptyValue affordance — an em-dash with the accessible name "No value", the same affordance
every other field widget draws for an absent value — because the record holds no boolean
there. The widget keeps no second truth table: a 'false' string that reaches it is a producer
that skipped its coercion, and the place to fix that is the data source.
Use Cases
- Feature Toggles: Enable/disable features
- Preferences: User settings and preferences
- Permissions: Access control flags
- Status: Active/inactive, published/draft states
- Agreements: Terms acceptance, consent flags
Cell Renderer
In tables/grids, BooleanCellRenderer draws a real boolean as a disabled checkbox — checked
for true, unchecked for false — named by the field's label. One field-name convention
changes the shape: a completion field (completed, is_completed, done, is_done) draws a
green "Completed" or an outlined "Not completed" indicator. Every other name draws the
checkbox, so false is a neutral unchecked box whatever the field is called: active,
enabled and verified read the same as any other boolean.
Only a real boolean is a value of a boolean column. @objectstack/spec declares the
runtime value of boolean / toggle as a bare JS boolean on the wire; the SQL 0/1 repair
and the 'true' / 'false' spellings belong to the producer boundaries (driver read-coercion,
CSV import). So null, undefined, [], {}, 0, 1, '', 'true' and 'false' all
render the shared EmptyValue affordance — an em-dash with the accessible name "No value" —
because the record holds no boolean there. A 'false' string that reaches this renderer is a
producer that skipped its coercion: fix it at the data source; the renderer keeps no second
truth table.
Styling
The boolean field uses the Switch component from Shadcn UI, providing:
- Smooth animations
- Accessible keyboard navigation
- Focus states
- Disabled states