Skip to content

Checkbox API

API reference docs for the React Checkbox component. Learn about the props, CSS, and other APIs of this exported module.

Component demos

Import

import Checkbox from '@mui/joy/Checkbox';
// or
import { Checkbox } from '@mui/joy';
Learn about the difference by reading this guide on minimizing bundle size.

Props

checked

If true, the component is checked.

Type:bool


checkedIcon

The icon to display when the component is checked.

Type:node

Default:<CheckIcon />


className

Class name applied to the root element.

Type:string


color

The color of the component. It supports those theme colors that make sense for this component.

To learn how to add your own colors, check out Themed components—Extend colors.

Type:'danger'
| 'neutral'
| 'primary'
| 'success'
| 'warning'
| string

Default:'neutral'


component

The component used for the root node. Either a string to use a HTML element or a component.

Type:elementType


defaultChecked

The default checked state. Use when the component is not controlled.

Type:bool


disabled

If true, the component is disabled.

Type:bool


disableIcon

If true, the checked icon is removed and the selected variant is applied on the action element instead.

Type:bool

Default:false


indeterminate

If true, the component appears indeterminate. This does not set the native input element to indeterminate due to inconsistent behavior across browsers. However, we set a data-indeterminate attribute on the input.

Type:bool

Default:false


indeterminateIcon

The icon to display when the component is indeterminate.

Type:node

Default:<IndeterminateIcon />


label

The label element next to the checkbox.

Type:node


name

The name attribute of the input.

Type:string


onChange

Callback fired when the state is changed.

Type:func

Signature:
function(event: React.ChangeEvent) => void
  • event The event source of the callback. You can pull out the new value by accessing event.target.value (string). You can pull out the new checked state by accessing event.target.checked (boolean).

overlay

If true, the root element's position is set to initial which allows the action area to fill the nearest positioned parent. This prop is useful for composing Checkbox with ListItem component.

Type:bool

Default:false


readOnly

If true, the component is read only.

Type:bool


required

If true, the input element is required.

Type:bool


size

The size of the component.

To learn how to add custom sizes to the component, check out Themed components—Extend sizes.

Type:'sm'
| 'md'
| 'lg'

Default:'md'


slotProps

The props used for each slot inside.

Type:{ action?: func
| object, checkbox?: func
| object, input?: func
| object, label?: func
| object, root?: func
| object }

Default:{}


slots

The components used for each slot inside.

See Slots API below for more details.

Type:{ action?: elementType, checkbox?: elementType, input?: elementType, label?: elementType, root?: elementType }

Default:{}


sx

The system prop that allows defining system overrides as well as additional CSS styles.

See the `sx` page for more details.

Type:Array<func
| object
| bool>
| func
| object


uncheckedIcon

The icon when checked is false.

Type:node


value

The value of the component. The DOM API casts this to a string. The browser uses "on" as the default value.

Type:Array<string>
| number
| string


variant

The global variant to use.

To learn how to add your own variants, check out Themed components—Extend variants.

Type:'outlined'
| 'plain'
| 'soft'
| 'solid'

Default:'solid'


The ref is forwarded to the root element.

Theme default props

You can use JoyCheckbox to change the default props of this component with the theme.


Slots

To learn how to customize the slot, check out the Overriding component structure guide.

root

The component that renders the root.

Class name: .MuiCheckbox-root

Default component: 'span'


checkbox

The component that renders the checkbox.

Class name: .MuiCheckbox-checkbox

Default component: 'span'


action

The component that renders the action.

Class name: .MuiCheckbox-action

Default component: 'span'


input

The component that renders the input.

Class name: .MuiCheckbox-input

Default component: 'input'


label

The component that renders the label.

Class name: .MuiCheckbox-label

Default component: 'label'


CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

.Mui-checkedSTATE

State class applied to the input component's checked class.


.Mui-disabledSTATE

State class applied to the input component's disabled class.


.Mui-focusVisibleSTATE

Class name applied to the root element if the switch has visible focus


.MuiCheckbox-colorContext

Class name applied to the root element when color inversion is triggered.

Rule name:colorContext


.MuiCheckbox-colorDanger

Class name applied to the root element if color="danger".

Rule name:colorDanger


.MuiCheckbox-colorNeutral

Class name applied to the root element if color="neutral".

Rule name:colorNeutral


.MuiCheckbox-colorPrimary

Class name applied to the root element if color="primary".

Rule name:colorPrimary


.MuiCheckbox-colorSuccess

Class name applied to the root element if color="success".

Rule name:colorSuccess


.MuiCheckbox-colorWarning

Class name applied to the root element if color="warning".

Rule name:colorWarning


.MuiCheckbox-indeterminate

State class applied to the root element if indeterminate={true}.

Rule name:indeterminate


.MuiCheckbox-sizeLg

Class name applied to the root element if size="lg".

Rule name:sizeLg


.MuiCheckbox-sizeMd

Class name applied to the root element if size="md".

Rule name:sizeMd


.MuiCheckbox-sizeSm

Class name applied to the root element if size="sm".

Rule name:sizeSm


.MuiCheckbox-variantOutlined

Class name applied to the root element if variant="outlined".

Rule name:variantOutlined


.MuiCheckbox-variantSoft

Class name applied to the root element if variant="soft".

Rule name:variantSoft


.MuiCheckbox-variantSolid

Class name applied to the root element if variant="solid".

Rule name:variantSolid



You can override the style of the component using one of these customization options: