<BooleanInput>
<BooleanInput />
renders a switch allowing users to set the value true
or false
to a record field.
Tip: This input doesn’t let users set a null
value - only true
or false
. Use the <NullableBooleanInput />
component if you have to handle non-required booleans.
Usage
import { BooleanInput } from 'react-admin';
<BooleanInput label="Commentable" source="commentable" />
Props
Prop | Required | Type | Default | Description |
---|---|---|---|---|
options |
Optional | Object |
{} |
Options object to pass to the underlying material-ui <Switch> component. |
<BooleanInput>
also accepts the common input props.
options
Use the options
prop to pass any option supported by the Material UI’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 Material UI Switch documentation for more details.