Switch bound to a boolean attribute — the “state now” affordance, where
checkbox is the “opt in” one.
| Builder | F.toggle(attribute: string): Toggle |
| Wire type key | toggle |
| Class chain | Toggle → BooleanField → Field |
| Detail projection | text-entry |
| Column counterpart | boolean cell, i.e. C.boolean(attribute) |
Example
import { F } from '@adonia/core'
F.toggle('isPublished').label('Published').onLabel('Live').offLabel('Hidden')Props
Beyond the shared field DSL:
| Prop | Declared on | Behaviour |
|---|---|---|
onLabel(text: string): this |
Toggle |
Caption shown beside the switch while it is on. |
offLabel(text: string): this |
Toggle |
Caption shown beside the switch while it is off. |
onColor(token: string): this |
Toggle |
Palette token for the switch’s on state ('green', 'amber', …). |
asInteger(): this |
BooleanField |
Stores the sqlite-shaped 0/1 integer instead of a boolean (§7.3). Needed when the model does NOT declare a boolean column consumer; with it, BooleanField.defaultDehydrate writes 1/0, which BooleanField.defaultHydrate reads straight back. |
Validation
Vine base: vine.boolean().
§11.1 mapping: vine.boolean().
Contributed by BooleanField.vineSchema() in packages/core/src/schema/fields/boolean_field.ts. The shared modifiers (required, nullable, requiredWhen, unique, optionality) are applied on top by Field.buildValidation, and a rules() override replaces the base entirely — the validator compiler never branches on the field class.
Declared in
packages/core/src/schema/fields/toggle.ts—Togglepackages/core/src/schema/fields/boolean_field.ts—BooleanField