BooleanInput
A switch that edits a boolean field.
Installation
pnpm dlx shadcn@latest add @chelone/boolean-inputA switch that edits a boolean field.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| alwaysOn | boolean | — | As a `<FilterForm>`/`<FilterButton>` filter: always shown, never in the add-filter menu. Read off the element by the filter layer, never by the input. |
| className | string | — | |
| defaultValue | boolean | null | — | ra precedence default; `false` when omitted (the switch starts off). |
| disabled | boolean | — | Native disabled state. |
| format | (value: unknown) => unknown | — | Read transform (raw form value → boolean the switch reflects). |
| helperText | ReactNode | — | Helper text rendered below the input; a string is translated. |
| id | string | — | Explicit element id; a generated `useId` value is used otherwise. |
| isRequired | boolean | — | Forces the required marker; ORed with `required()` detection on `validate`. |
| label | ReactNode | — | The input label. A string is translated; a ReactNode renders as-is; `false` (or `""`) renders no label. |
| name | string | — | Legacy field-name alias (ra parity); the wiring uses `source`. |
| onBlur | (event: unknown) => void | — | |
| onChange | (value: boolean) => void | — | Chained AFTER the parsed boolean is written to the form. |
| onFocus | (event: FocusEvent<HTMLButtonElement>) => void | — | |
| options | SwitchProps & RefAttributes<HTMLButtonElement> & { size?: "default" | "sm" } | — | Extra props forwarded to the underlying shadcn `<Switch>`. |
| parse | (value: unknown) => unknown | — | Write transform (boolean → stored value). |
| readOnly | boolean | — | Native read-only state. |
| resource | string | — | Override the ambient resource (used to resolve the default label key). |
| source | string | — | The field path RELATIVE to the ambient source scope. |
| validate | Validator | readonly Validator[] | — | ra-contract validators — composed, first error wins. |