Skip to main content

BooleanInput

Collects a boolean as a switch.

In a filter the dispatcher swaps it for TriStateBooleanInput, a three-way toggle — a checkbox cannot express “I don't care”, which is what an unset filter means.

Example​

<BooleanInput source="is_available" />

Props​

The component wraps React Admin's BooleanInput and forwards its props; it only fixes the margins so the control lines up with the text inputs around it.

NameTypeDefaultDescription
source (required)string—Name of the field in the form record
labelstring | ReactElement | falselabel from the schemafalse hides the label
helperTextstring | ReactElement | falsehelpText from the schemaText under the input
defaultValuebooleandefaultValue from the schemaInitial value in a create form
disabledbooleanfalseDisables the switch

TriStateBooleanInput​

NameTypeDefaultDescription
source (required)string—Name of the filter
labelstring | ReactElement | falselabel from the schemafalse hides the label next to the toggle

The three positions store true, false and ''. The empty string is what clears the filter — undefined would leave the previous value in place.

Schema mapping​

Any field with type: "boolean":

{"name": "is_available", "type": "boolean", "defaultValue": true}
class Product(models.Model):
is_available = models.BooleanField(default=True)

See also​