> ## Documentation Index
> Fetch the complete documentation index at: https://araf.badr.co.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkbox

> A binary selection control for checking or unchecking an option — supports labels, descriptions, indeterminate state, and groups.

## Overview

<div style={{display:"flex",gap:"24px",flexWrap:"wrap",padding:"28px 24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb",alignItems:"flex-start"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"6px",alignItems:"center"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #D0D5DD",background:"#fff"}} />

    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Unchecked</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px",alignItems:"center"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #0479CE",background:"#0479CE",display:"flex",alignItems:"center",justifyContent:"center"}}>
      <svg width="11" height="8" viewBox="0 0 11 8" fill="none">
        <path d="M1 4L4 7L10 1" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </div>

    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Checked</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px",alignItems:"center"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #0479CE",background:"#0479CE",display:"flex",alignItems:"center",justifyContent:"center"}}>
      <svg width="10" height="2" viewBox="0 0 10 2" fill="none">
        <path d="M1 1H9" stroke="white" strokeWidth="2" strokeLinecap="round" />
      </svg>
    </div>

    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Indeterminate</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px",alignItems:"center"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #E5E7EB",background:"#F9FAFB",cursor:"not-allowed"}} />

    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Disabled</span>
  </div>

  <div style={{display:"flex",flexDirection:"column",gap:"6px",alignItems:"center"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #E5E7EB",background:"#F9FAFB",display:"flex",alignItems:"center",justifyContent:"center",cursor:"not-allowed"}}>
      <svg width="11" height="8" viewBox="0 0 11 8" fill="none">
        <path d="M1 4L4 7L10 1" stroke="#D0D5DD" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </div>

    <span style={{fontSize:"11px",color:"#71717a",fontFamily:"Inter,sans-serif"}}>Disabled checked</span>
  </div>
</div>

**Checkbox** allows users to select one or more items from a list, or toggle a single setting on or off. It supports labels, descriptions, disabled states, and an indeterminate state for "select all" patterns.

***

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @araf-ds/core
  ```

  ```bash yarn theme={null}
  yarn add @araf-ds/core
  ```

  ```bash pnpm theme={null}
  pnpm add @araf-ds/core
  ```
</CodeGroup>

***

## Usage

```tsx theme={null}
import { Checkbox } from "@araf-ds/core"

export default function Example() {
  return (
    <Checkbox label="Accept terms and conditions" />
  )
}
```

***

## Variants

### Basic

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",alignItems:"center",gap:"10px"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #D0D5DD",background:"#fff",flexShrink:0}} />

    <span style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Accept terms and conditions</span>
  </div>
</div>

```tsx theme={null}
<Checkbox label="Accept terms and conditions" />
```

### Checked

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",alignItems:"center",gap:"10px"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #0479CE",background:"#0479CE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}}>
      <svg width="11" height="8" viewBox="0 0 11 8" fill="none">
        <path d="M1 4L4 7L10 1" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </div>

    <span style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Subscribe to newsletter</span>
  </div>
</div>

```tsx theme={null}
<Checkbox label="Subscribe to newsletter" defaultChecked />
```

### With Description

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",alignItems:"flex-start",gap:"10px"}}>
    <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #0479CE",background:"#0479CE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:"2px"}}>
      <svg width="11" height="8" viewBox="0 0 11 8" fill="none">
        <path d="M1 4L4 7L10 1" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </div>

    <div>
      <div style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Enable notifications</div>
      <div style={{fontSize:"13px",color:"#667085",fontFamily:"Inter,sans-serif",marginTop:"2px"}}>Receive email updates about your account activity.</div>
    </div>
  </div>
</div>

```tsx theme={null}
<Checkbox
  label="Enable notifications"
  description="Receive email updates about your account activity."
  defaultChecked
/>
```

### Disabled

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"12px"}}>
    <div style={{display:"flex",alignItems:"center",gap:"10px",opacity:0.5,cursor:"not-allowed"}}>
      <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #D0D5DD",background:"#F9FAFB",flexShrink:0}} />

      <span style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Admin access</span>
    </div>

    <div style={{display:"flex",alignItems:"center",gap:"10px",opacity:0.5,cursor:"not-allowed"}}>
      <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #D0D5DD",background:"#F9FAFB",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}}>
        <svg width="11" height="8" viewBox="0 0 11 8" fill="none">
          <path d="M1 4L4 7L10 1" stroke="#D0D5DD" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      </div>

      <span style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Super admin</span>
    </div>
  </div>
</div>

```tsx theme={null}
<Checkbox label="Admin access" disabled />
<Checkbox label="Super admin" disabled defaultChecked />
```

### Indeterminate (Select All)

Use the indeterminate state to represent a "select all" parent checkbox when only some children are selected.

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"12px"}}>
    <div style={{display:"flex",alignItems:"center",gap:"10px"}}>
      <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #0479CE",background:"#0479CE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}}>
        <svg width="10" height="2" viewBox="0 0 10 2" fill="none">
          <path d="M1 1H9" stroke="white" strokeWidth="2" strokeLinecap="round" />
        </svg>
      </div>

      <span style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>Select all</span>
    </div>

    <div style={{paddingLeft:"28px",display:"flex",flexDirection:"column",gap:"10px"}}>
      <div style={{display:"flex",alignItems:"center",gap:"10px"}}>
        <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #0479CE",background:"#0479CE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}}>
          <svg width="11" height="8" viewBox="0 0 11 8" fill="none">
            <path d="M1 4L4 7L10 1" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
          </svg>
        </div>

        <span style={{fontSize:"14px",color:"#344054",fontFamily:"Inter,sans-serif"}}>Design</span>
      </div>

      <div style={{display:"flex",alignItems:"center",gap:"10px"}}>
        <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #D0D5DD",background:"#fff",flexShrink:0}} />

        <span style={{fontSize:"14px",color:"#344054",fontFamily:"Inter,sans-serif"}}>Engineering</span>
      </div>

      <div style={{display:"flex",alignItems:"center",gap:"10px"}}>
        <div style={{width:"18px",height:"18px",borderRadius:"4px",border:"1.5px solid #D0D5DD",background:"#fff",flexShrink:0}} />

        <span style={{fontSize:"14px",color:"#344054",fontFamily:"Inter,sans-serif"}}>Product</span>
      </div>
    </div>
  </div>
</div>

```tsx theme={null}
const [items, setItems] = useState([true, false, false]);
const allChecked = items.every(Boolean);
const someChecked = items.some(Boolean) && !allChecked;

<Checkbox
  checked={allChecked ? true : someChecked ? "indeterminate" : false}
  onCheckedChange={(checked) => setItems(items.map(() => !!checked))}
  label="Select all"
/>
```

***

## Checkbox Group Pattern

<div style={{padding:"24px",background:"#f9fafb",borderRadius:"12px",border:"1px solid #e5e7eb"}}>
  <div style={{display:"flex",flexDirection:"column",gap:"12px"}}>
    {["Design","Engineering","Product"].map((opt, i) => (
            <div key={opt} style={{display:"flex",alignItems:"center",gap:"10px"}}>
              <div style={{width:"18px",height:"18px",borderRadius:"4px",border:`1.5px solid ${i===0?"#0479CE":"#D0D5DD"}`,background:i===0?"#0479CE":"#fff",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}}>
                {i===0 && <svg width="11" height="8" viewBox="0 0 11 8" fill="none"><path d="M1 4L4 7L10 1" stroke="white" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>}
              </div>
              <span style={{fontSize:"14px",fontWeight:500,color:"#344054",fontFamily:"Inter,sans-serif"}}>{opt}</span>
            </div>
          ))}
  </div>
</div>

```tsx theme={null}
const options = ["Design", "Engineering", "Product"];
const [selected, setSelected] = useState<string[]>(["Design"]);

const toggle = (val: string) =>
  setSelected((prev) =>
    prev.includes(val) ? prev.filter((v) => v !== val) : [...prev, val]
  );

<div className="flex flex-col gap-3">
  {options.map((opt) => (
    <Checkbox
      key={opt}
      label={opt}
      checked={selected.includes(opt)}
      onCheckedChange={() => toggle(opt)}
    />
  ))}
</div>
```

***

## API Reference

<ParamField path="checked" type="boolean | 'indeterminate'">
  Controlled checked state. Use `"indeterminate"` to show a dash/mixed state.
</ParamField>

<ParamField path="defaultChecked" type="boolean" default="false">
  Uncontrolled initial checked state.
</ParamField>

<ParamField path="onCheckedChange" type="(checked: boolean) => void">
  Callback fired when the checked state changes.
</ParamField>

<ParamField path="label" type="string">
  Label text displayed next to the checkbox.
</ParamField>

<ParamField path="description" type="string">
  Supporting description shown below the label.
</ParamField>

<ParamField path="disabled" type="boolean" default="false">
  Disables the checkbox and applies the disabled visual style.
</ParamField>

<ParamField path="id" type="string">
  HTML `id` for associating a custom `<label>` element via `htmlFor`.
</ParamField>

<ParamField path="className" type="string">
  Additional Tailwind classes for custom overrides.
</ParamField>

***

## Accessibility

* Checkbox uses a native `<input type="checkbox">` element for full keyboard and screen reader support
* Label is associated via `htmlFor` / `id` — clicking the label also toggles the checkbox
* `description` is linked via `aria-describedby` so screen readers announce it after the label
* `disabled` uses the native `disabled` attribute, removing the element from tab order
* Indeterminate state is set via `aria-checked="mixed"` — screen readers will announce "mixed"
* Focus ring (`0 0 0 4px #CDE4F5`) meets WCAG 2.1 AA contrast requirements

***

## Do's & Don'ts

<CardGroup cols={2}>
  <Card title="Do" icon="check" iconType="solid" color="#16A34A">
    * Use checkbox for multi-select or toggleable settings
    * Always provide a visible label — never a checkbox alone
    * Use the indeterminate state for "select all" parent checkboxes
    * Group related checkboxes under a clear section heading
  </Card>

  <Card title="Don't" icon="xmark" iconType="solid" color="#DC2626">
    * Don't use checkbox for exclusive single-selection — use Radio Group instead
    * Don't use checkbox for immediate actions — use Switch instead
    * Don't stack more than 8 checkboxes without grouping or filtering
    * Don't disable without explaining why in nearby helper text
  </Card>
</CardGroup>
