Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 1.71 KB

BooleanInput.md

File metadata and controls

50 lines (33 loc) · 1.71 KB
layout title
default
The BooleanInput Component

<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:

{% raw %}

import { BooleanInput } from 'react-admin';
import FavoriteIcon from '@mui/icons-material/Favorite';

<BooleanInput source="favorite" options={{ checkedIcon: <FavoriteIcon /> }} />

{% endraw %}

CustomBooleanInputCheckIcon

Refer to Material UI Switch documentation for more details.