BooleanInput

A switch that edits a boolean field.

Installation

pnpm dlx shadcn@latest add @chelone/boolean-input
Loading preview…

A switch that edits a boolean field.

Props

PropTypeDefaultDescription
alwaysOnboolean—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.
classNamestring—
defaultValueBooleanDefault<TRecord, TPath>—ra precedence default; `false` when omitted (the switch starts off).
disabledboolean—Native disabled state.
format(value: boolean) => boolean—Read transform (guarded form value → boolean the switch reflects).
helperTextReactNode—Helper text rendered below the input; a string is translated.
idstring—Explicit element id; a generated `useId` value is used otherwise.
isRequiredboolean—Forces the required marker; ORed with `required()` detection on `validate`.
labelReactNode—The input label. A string is translated; a ReactNode renders as-is; `false` (or `""`) renders no label.
namestring—Legacy field-name alias (ra parity); the wiring uses `source`.
onBlur(event: FocusEvent<Element, Element>) => void—
onChange(value: boolean) => void—Chained AFTER the parsed boolean is written to the form.
onFocus(event: FocusEvent<HTMLButtonElement>) => void—
optionsSwitchProps & RefAttributes<HTMLButtonElement> & { size?: "default" | "sm" }—Extra props forwarded to the underlying shadcn `<Switch>`.
parse(value: boolean) => boolean | null—Write transform (the switch's boolean → stored value).
readOnlyboolean—Native read-only state.
resourcestring—Override the ambient resource (used to resolve the default label key).
sourceTPath—The field path RELATIVE to the ambient source scope.
validateValidator | readonly Validator[]—ra-contract validators — composed, first error wins.