<BooleanInput>
<BooleanInput />
is a toggle button allowing you to attribute a true
or false
value to a record field.
import { BooleanInput } from 'react-admin';
<BooleanInput label="Commentable" source="commentable" />
This input does not handle null
values. You would need the <NullableBooleanInput />
component if you have to handle non-set booleans.
You can use the options
prop to pass any option supported by the MUI’s Switch
components. For example, here’s how to set a custom checked icon:
import { BooleanInput } from 'react-admin';
import FavoriteIcon from '@mui/icons-material/Favorite';
<BooleanInput source="favorite" options={{ checkedIcon: <FavoriteIcon /> }} />
Refer to MUI Switch documentation for more details.
<BooleanInput>
also accepts the common input props.