Skip to content

BooleanField

Displays a boolean value as a check or close icon with a tooltip label.

import { BooleanField } from '@/components/admin';
<BooleanField source="is_published" />

By default, true renders a Check icon and false renders an X icon. Hovering over the icon shows a tooltip with the value label.

PropRequiredTypeDefaultDescription
sourceRequiredstring-Field name
classNameOptionalstring-Classes applied to the icon
defaultValueOptionalunknown-Fallback value when field is absent
emptyOptionalReactNodenullRendered when value is neither boolean nor truthy (with looseValue)
FalseIconOptionalLucideIcon | nullXIcon for falsy values; null renders nothing
looseValueOptionalbooleanfalseTreat any truthy value as true
recordOptionalobjectRecord from contextExplicit record override
TrueIconOptionalLucideIcon | nullCheckIcon for truthy values; null renders nothing
valueLabelFalseOptionalstring"false"Tooltip text for falsy value (supports i18n keys)
valueLabelTrueOptionalstring"true"Tooltip text for truthy value (supports i18n keys)

Replace the default check/cross with any Lucide icon:

import { Heart, HeartOff } from 'lucide-react';
<BooleanField
source="liked"
TrueIcon={Heart}
FalseIcon={HeartOff}
valueLabelTrue="Liked"
valueLabelFalse="Not liked"
/>

Pass null to suppress the icon for one state:

<BooleanField source="is_published" FalseIcon={null} />

The valueLabelTrue and valueLabelFalse props set the tooltip text. They support i18n keys, which will be translated via the i18nProvider:

<BooleanField
source="is_published"
valueLabelTrue="resources.posts.fields.is_published.true"
valueLabelFalse="resources.posts.fields.is_published.false"
/>

If no label is provided, the field falls back to ra.boolean.true / ra.boolean.false from the i18nProvider.

By default, the field only renders an icon when the value is strictly true or false. Set looseValue to treat any truthy/falsy value (e.g. 1, 0, "yes") as boolean:

<BooleanField source="is_active" looseValue />

When the field value is absent or non-boolean (and looseValue is not set), empty is rendered:

<BooleanField
source="is_published"
empty={<span className="text-muted-foreground">—</span>}
/>