> ## Documentation Index
> Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkbox

> Select independent options with checked and indeterminate states.

export const StoryEmbed = ({storyId, title, height = 120}) => <>
    <Tabs>
      <Tab title="Light">
        <iframe title={`${title} (light)`} src={`https://storybook.twenty.com/iframe.html?id=${storyId}&viewMode=story&globals=colorScheme:light`} width="100%" height={height} loading="lazy" allow="clipboard-write" style={{
  border: 0
}} />
      </Tab>
      <Tab title="Dark">
        <iframe title={`${title} (dark)`} src={`https://storybook.twenty.com/iframe.html?id=${storyId}&viewMode=story&globals=colorScheme:dark`} width="100%" height={height} loading="lazy" allow="clipboard-write" style={{
  border: 0
}} />
      </Tab>
    </Tabs>
    <a href={`https://storybook.twenty.com/?path=/story/${storyId}`}>
      Open in Storybook
    </a>
  </>;

Use `Checkbox` when each option can be selected independently. For a mutually exclusive choice, use [RadioGroup](/ui/primitives/input/radio-group).

<StoryEmbed storyId="ui-input-checkbox-checkbox--display" title="Checkbox example" height={100} />

## Usage

### Uncontrolled state

Use `defaultChecked` to set the initial checked state. The checkbox owns subsequent changes.

```tsx theme={null}
import { useId } from 'react';
import { Checkbox } from 'twenty-ui/primitives/input';
import { Text } from 'twenty-ui/primitives/typography';

export const EmailPreference = () => {
  const checkboxId = useId();

  return (
    <label
      htmlFor={checkboxId}
      style={{ display: 'inline-flex', alignItems: 'center', gap: 8 }}
    >
      <Checkbox id={checkboxId} name="updates" value="email" defaultChecked />
      <Text render={<span />}>Receive product updates</Text>
    </label>
  );
};
```

A checked, named checkbox contributes its value to a form. Set `uncheckedValue` if the form should also submit a value when it is unchecked.

## Appearance and interaction

Compare checked, indeterminate, and disabled states, then choose the color, size, shape, and variant independently. The enabled examples can be toggled.

<StoryEmbed storyId="ui-input-checkbox-checkbox--catalog" title="Appearance and interaction for checkbox" height={400} />

| Prop | Values | Default |
| - | - | - |
| `size` | `sm`, `md` | `sm` |
| `variant` | `solid`, `outline`, `soft` | `solid` |
| `shape` | `square`, `round` | `square` |
| `color` | `accent`, `success`, `warning` | `accent` |

Tab focuses the checkbox and Space toggles it. Clicking its label also toggles it. Use `disabled` to prevent interaction, or `readOnly` when the value should remain unchanged while the control stays focusable. Keep meaning in the label rather than communicating it through color alone.

## Controlled state

Pass `checked` and update it with `onCheckedChange` to own the same preference in React state. The callback receives the next boolean and event details.

```tsx theme={null}
import { useId, useState } from 'react';
import { Checkbox } from 'twenty-ui/primitives/input';
import { Text } from 'twenty-ui/primitives/typography';

export const EmailPreference = () => {
  const checkboxId = useId();
  const [checked, setChecked] = useState(true);

  return (
    <label
      htmlFor={checkboxId}
      style={{ display: 'inline-flex', alignItems: 'center', gap: 8 }}
    >
      <Checkbox
        id={checkboxId}
        name="updates"
        value="email"
        checked={checked}
        onCheckedChange={setChecked}
      />
      <Text render={<span />}>Receive product updates</Text>
    </label>
  );
};
```

## Indeterminate state

An indeterminate checkbox represents a partial selection. Derive it from the child options independently of the checkbox's checked state.

```tsx theme={null}
import { useState } from 'react';
import { Checkbox } from 'twenty-ui/primitives/input';

export const ColumnSelection = () => {
  const [showEmail, setShowEmail] = useState(true);
  const [showPhone, setShowPhone] = useState(false);

  return (
    <fieldset>
      <legend>Visible columns</legend>
      <label>
        <Checkbox
          checked={showEmail && showPhone}
          indeterminate={showEmail !== showPhone}
          onCheckedChange={(checked) => {
            setShowEmail(checked);
            setShowPhone(checked);
          }}
        />
        All columns
      </label>
      <label>
        <Checkbox checked={showEmail} onCheckedChange={setShowEmail} />
        Email
      </label>
      <label>
        <Checkbox checked={showPhone} onCheckedChange={setShowPhone} />
        Phone
      </label>
    </fieldset>
  );
};
```

## Parts and custom content

`Checkbox` assembles the styled root and its default check and indeterminate icons. Use `Checkbox.Root` with `Checkbox.Indicator` to own the indicator content. Root owns state and box appearance; Indicator renders the content you supply.

```tsx theme={null}
import { IconCheck } from 'twenty-ui/icon';
import { Checkbox } from 'twenty-ui/primitives/input';

export const CustomPreference = () => (
  <Checkbox.Root aria-label="Updates" defaultChecked>
    <Checkbox.Indicator>
      <IconCheck aria-hidden />
    </Checkbox.Indicator>
  </Checkbox.Root>
);
```

`CheckboxRootProps` and `CheckboxIndicatorProps` are public types exported from `twenty-ui/primitives/input`. Both parts accept native attributes, handlers, refs, `render`, and state-based `className` and `style` callbacks. Root's `ref` targets the visible control; `inputRef` targets the native input. The part ref targets its rendered element. Pass `nativeButton` with `render={<button />}` when replacing Root with a button. Appearance props belong on Root; explicit classes and styles are merged with the defaults.

Indicator receives checked and indeterminate state, including transition state. Set `keepMounted` to retain an unchecked indicator in the DOM; the default styling hides it with opacity. Override its `style` or `className` for custom transitions.

<StoryEmbed storyId="ui-input-checkbox-parts--composition" title="Checkbox part composition" height={100} />

The callable assembly and its `CheckboxProps` type remain supported. Replace the assembly with Root and its part when supplying custom icons instead of appending another part to the assembly's children.

For controlled form reset, handle the form's `onReset` and restore `checked` to your initial value. Base UI 1.8 does not restore uncontrolled component state on native form reset. `required`, `form`, `value`, and `uncheckedValue` keep the upstream native input behavior.

## Props

The reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.

<ParamField body="checked" type="boolean">
  Whether the checkbox is currently ticked.

  To render an uncontrolled checkbox, use the `defaultChecked` prop instead.
</ParamField>

<ParamField body="className" type="string | ((state: CheckboxRootState) => string | undefined)">
  CSS class applied to the element, or a function that
  returns a class based on the component's state.
</ParamField>

<ParamField body="color" type="&#x22;accent&#x22; | &#x22;success&#x22; | &#x22;warning&#x22;" default="accent">
  Color used while the checkbox is checked or indeterminate.
</ParamField>

<ParamField body="defaultChecked" type="boolean" default="false">
  Whether the checkbox is initially ticked.

  To render a controlled checkbox, use the `checked` prop instead.
</ParamField>

<ParamField body="disabled" type="boolean" default="false">
  Whether the component should ignore user interaction.
</ParamField>

<ParamField body="form" type="string">
  Identifies the form that owns the hidden input.
  Useful when the checkbox is rendered outside the form.
</ParamField>

<ParamField body="hoverable" type="boolean" default="true">
  Adds padding and a hover background around the box.
</ParamField>

<ParamField body="id" type="string">
  The id of the input element.
</ParamField>

<ParamField body="indeterminate" type="boolean" default="false">
  Whether the checkbox is in a mixed state: neither ticked, nor unticked.
</ParamField>

<ParamField body="inputRef" type="Ref<HTMLInputElement>">
  A ref to access the hidden `<input>` element.
</ParamField>

<ParamField body="name" type="string">
  Identifies the field when a form is submitted.
</ParamField>

<ParamField body="nativeButton" type="boolean" default="false">
  Whether the component renders a native `<button>` element when replacing it
  via the `render` prop.
  Set to `true` if the rendered element is a native button.
</ParamField>

<ParamField body="onCheckedChange" type="((checked: boolean, eventDetails: { reason: &#x22;none&#x22;; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">
  Event handler called when the checkbox is ticked or unticked.
</ParamField>

<ParamField body="parent" type="boolean" default="false">
  Whether the checkbox controls a group of child checkboxes.

  Must be used in a [Checkbox Group](https://base-ui.com/react/components/checkbox-group).
</ParamField>

<ParamField body="readOnly" type="boolean" default="false">
  Whether the user should be unable to tick or untick the checkbox.
</ParamField>

<ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxRootState>">
  Allows you to replace the component's HTML element
  with a different tag, or compose it with another component.

  Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>

<ParamField body="required" type="boolean" default="false">
  Whether the user must tick the checkbox before submitting a form.
</ParamField>

<ParamField body="shape" type="&#x22;round&#x22; | &#x22;square&#x22;" default="square">
  Corner shape of the box.
</ParamField>

<ParamField body="size" type="&#x22;md&#x22; | &#x22;sm&#x22;" default="sm">
  Visual size of the checkbox.
</ParamField>

<ParamField body="style" type="CSSProperties | ((state: CheckboxRootState) => CSSProperties | undefined)">
  Style applied to the element, or a function that
  returns a style object based on the component's state.
</ParamField>

<ParamField body="uncheckedValue" type="string">
  The value submitted with the form when the checkbox is unchecked.
  By default, unchecked checkboxes do not submit any value, matching native checkbox behavior.
</ParamField>

<ParamField body="value" type="string">
  The checkbox's value. Identifies it within a [Checkbox Group](https://base-ui.com/react/components/checkbox-group), falling back to `name` when omitted.
  When submitting a form, a checked box submits `value`; with no `value`, it submits the native "on".
</ParamField>

<ParamField body="variant" type="&#x22;outline&#x22; | &#x22;soft&#x22; | &#x22;solid&#x22;" default="solid">
  Visual style of the box: filled, outlined, or tinted.
</ParamField>

### Checkbox.Root

<ParamField body="Root.checked" type="boolean">
  Whether the checkbox is currently ticked.

  To render an uncontrolled checkbox, use the `defaultChecked` prop instead.
</ParamField>

<ParamField body="Root.className" type="string | ((state: CheckboxRootState) => string | undefined)">
  CSS class applied to the element, or a function that
  returns a class based on the component's state.
</ParamField>

<ParamField body="Root.color" type="&#x22;accent&#x22; | &#x22;success&#x22; | &#x22;warning&#x22;" default="accent">
  Color used while the checkbox is checked or indeterminate.
</ParamField>

<ParamField body="Root.defaultChecked" type="boolean" default="false">
  Whether the checkbox is initially ticked.

  To render a controlled checkbox, use the `checked` prop instead.
</ParamField>

<ParamField body="Root.disabled" type="boolean" default="false">
  Whether the component should ignore user interaction.
</ParamField>

<ParamField body="Root.form" type="string">
  Identifies the form that owns the hidden input.
  Useful when the checkbox is rendered outside the form.
</ParamField>

<ParamField body="Root.hoverable" type="boolean" default="true">
  Adds padding and a hover background around the box.
</ParamField>

<ParamField body="Root.id" type="string">
  The id of the input element.
</ParamField>

<ParamField body="Root.indeterminate" type="boolean" default="false">
  Whether the checkbox is in a mixed state: neither ticked, nor unticked.
</ParamField>

<ParamField body="Root.inputRef" type="Ref<HTMLInputElement>">
  A ref to access the hidden `<input>` element.
</ParamField>

<ParamField body="Root.name" type="string">
  Identifies the field when a form is submitted.
</ParamField>

<ParamField body="Root.nativeButton" type="boolean" default="false">
  Whether the component renders a native `<button>` element when replacing it
  via the `render` prop.
  Set to `true` if the rendered element is a native button.
</ParamField>

<ParamField body="Root.onCheckedChange" type="((checked: boolean, eventDetails: { reason: &#x22;none&#x22;; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void)">
  Event handler called when the checkbox is ticked or unticked.
</ParamField>

<ParamField body="Root.parent" type="boolean" default="false">
  Whether the checkbox controls a group of child checkboxes.

  Must be used in a [Checkbox Group](https://base-ui.com/react/components/checkbox-group).
</ParamField>

<ParamField body="Root.readOnly" type="boolean" default="false">
  Whether the user should be unable to tick or untick the checkbox.
</ParamField>

<ParamField body="Root.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxRootState>">
  Allows you to replace the component's HTML element
  with a different tag, or compose it with another component.

  Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>

<ParamField body="Root.required" type="boolean" default="false">
  Whether the user must tick the checkbox before submitting a form.
</ParamField>

<ParamField body="Root.shape" type="&#x22;round&#x22; | &#x22;square&#x22;" default="square">
  Corner shape of the box.
</ParamField>

<ParamField body="Root.size" type="&#x22;md&#x22; | &#x22;sm&#x22;" default="sm">
  Visual size of the checkbox.
</ParamField>

<ParamField body="Root.style" type="CSSProperties | ((state: CheckboxRootState) => CSSProperties | undefined)">
  Style applied to the element, or a function that
  returns a style object based on the component's state.
</ParamField>

<ParamField body="Root.uncheckedValue" type="string">
  The value submitted with the form when the checkbox is unchecked.
  By default, unchecked checkboxes do not submit any value, matching native checkbox behavior.
</ParamField>

<ParamField body="Root.value" type="string">
  The checkbox's value. Identifies it within a [Checkbox Group](https://base-ui.com/react/components/checkbox-group), falling back to `name` when omitted.
  When submitting a form, a checked box submits `value`; with no `value`, it submits the native "on".
</ParamField>

<ParamField body="Root.variant" type="&#x22;outline&#x22; | &#x22;soft&#x22; | &#x22;solid&#x22;" default="solid">
  Visual style of the box: filled, outlined, or tinted.
</ParamField>

### Checkbox.Indicator

<ParamField body="Indicator.className" type="string | ((state: CheckboxIndicatorState) => string | undefined)">
  CSS class applied to the element, or a function that
  returns a class based on the component's state.
</ParamField>

<ParamField body="Indicator.keepMounted" type="boolean" default="false">
  Whether to keep the element in the DOM when the checkbox is not checked.
</ParamField>

<ParamField body="Indicator.render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, CheckboxIndicatorState>">
  Allows you to replace the component's HTML element
  with a different tag, or compose it with another component.

  Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>

<ParamField body="Indicator.style" type="CSSProperties | ((state: CheckboxIndicatorState) => CSSProperties | undefined)">
  Style applied to the element, or a function that
  returns a style object based on the component's state.
</ParamField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.