Skip to Content
ComponentsFormsCheckbox

Checkbox

A form component that allows users to select one or more independent options from a list. 
For more information on this component configuration, visit Radix UI 

Disabled

Use the disabled attr or the disabled class to disable a component.

Valid

Use the data-valid attr or the valid class to indicate an valid state.

Name is valid

Invalid

Use the data-invalid attr or the invalid class to indicate an invalid state.

Name is required

Controlled

Use the checked and onCheckedChange props when you need to control the value externally.

Uncontrolled

Use the name prop to include the value in the form submission.


Sizes

Use the checkbox-{size} class to control the component size.

Size values can include:smmdlg.

For more information on all available sizing utilities, visit Tailwind 

Variants

Use the variant and palette classes to control the appereance of the component.

Variant values can include solidoutlinesurfacesubtle.
Color palettes can include primaryneutral. For extra palettes such as warning error and more, refer to the Colors section.

Customizing

globals.css
:root { --ex-checkbox-cursor: default; --ex-checkbox-gap-x-sm: calc(var(--spacing) * 2); --ex-checkbox-gap-x-md: calc(var(--spacing) * 2.5); --ex-checkbox-gap-x-lg: calc(var(--spacing) * 3); --ex-checkbox-radius-sm: var(--radius-sm); --ex-checkbox-radius-md: var(--radius-sm); --ex-checkbox-radius-lg: var(--radius-sm); --ex-checkbox-size-sm: calc(var(--spacing) * 4); --ex-checkbox-size-md: calc(var(--spacing) * 5); --ex-checkbox-size-lg: calc(var(--spacing) * 6); --ex-checkbox-indicator-font-size-sm: var(--text-xs); --ex-checkbox-indicator-font-size-md: var(--text-base); --ex-checkbox-indicator-font-size-lg: var(--text-lg); --ex-checkbox-label-font-family: var(--font-sans); --ex-checkbox-label-font-weight: var(--font-weight-medium); --ex-checkbox-label-font-size-sm: var(--text-xs); --ex-checkbox-label-font-size-md: var(--text-sm); --ex-checkbox-label-font-size-lg: var(--text-base); }

API

For more information on this component configuration, visit Radix UI 

Checkbox

ElementSelector
Checkbox.ex-checkbox
PropTypeDefault
asElementTypediv
asChildbooleanfalse

Checkbox Control

ElementSelector
Checkbox.ex-checkbox-control
PropTypeDefault
asElementTypebutton
asChildbooleanfalse
checkedbooleanfalse
defaultCheckedbooleanfalse
disabledbooleanfalse
namestring
requiredbooleanfalse
valuestring
onCheckedChangefunction

Checkbox Indicator

ElementSelector
Checkbox.ex-checkbox-indicator
PropTypeDefault
asElementTypediv
asChildbooleanfalse
forceMountbooleanfalse

Checkbox Label

ElementSelector
Checkbox.ex-checkbox-label
PropTypeDefault
asElementTypelabel
asChildbooleanfalse
Last updated on