# Checkbox

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/checkbox
- **Markdown:** https://refast.fastapicloud.dev/docs/components/checkbox.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/form_inputs/checkbox.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

Single checkbox input and grouped multi-select checkboxes.

```python
from refast.components import Checkbox, CheckboxGroup

# Single checkbox
Checkbox(
    name="agree",
    value="yes",
    label="I agree to the terms of service",
    required=True,
    on_change=ctx.callback(handle_toggle),
)

# Grouped checkboxes
CheckboxGroup(
    name="interests",
    label="Your Interests",
    value=["python", "react"],
    orientation="vertical",
    on_change=ctx.callback(handle_change),
    children=[
        Checkbox(value="python", label="Python"),
        Checkbox(value="react", label="React"),
        Checkbox(value="rust", label="Rust"),
    ],
)
```

Single Checkbox

```python
Checkbox(
    name="agree",
    value="yes",
    label="I agree to the terms of service",
    checked=False,
    disabled=False,
    error=None,
    on_change=ctx.callback(handle_toggle),
)
```

CheckboxGroup

```python
CheckboxGroup(
    name="fruits",
    label="Favourite Fruits",
    value=['apple'],
    orientation="vertical",
    on_change=ctx.callback(handle_change),
    children=[
        Checkbox(value="apple", label="Apple"),
        Checkbox(value="banana", label="Banana"),
        Checkbox(value="cherry", label="Cherry"),
    ],
)
```

## Checkbox Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `name` | `str \| None` | `None` | HTML name attribute |
| `value` | `str \| None` | `None` | Value submitted when checked |
| `label` | `str \| None` | `None` | Label text |
| `description` | `str \| None` | `None` | Help text below the checkbox |
| `checked` | `bool` | `False` | Controlled checked state |
| `default_checked` | `bool` | `False` | Uncontrolled initial state |
| `required` | `bool` | `False` | Shows required asterisk |
| `disabled` | `bool` | `False` | Disables interaction |
| `error` | `str \| None` | `None` | Error message |
| `on_change` | `Callback \| None` | `None` | Fired when checked state changes |
| `class_name` | `str` | `""` | Extra Tailwind classes |

## CheckboxGroup Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `name` | `str \| None` | `None` | Group name for form submission |
| `children` | `list[Checkbox]` | `[]` | Checkbox items |
| `label` | `str \| None` | `None` | Group label |
| `description` | `str \| None` | `None` | Help text below label |
| `value` | `list[str]` | `[]` | Controlled list of selected values |
| `default_value` | `list[str] \| None` | `None` | Uncontrolled initial values |
| `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Layout orientation |
| `required` | `bool` | `False` | Shows required asterisk |
| `disabled` | `bool` | `False` | Disables all checkboxes in the group |
| `error` | `str \| None` | `None` | Error message |
| `on_change` | `Callback \| None` | `None` | Fired with the new list of selected values |
| `class_name` | `str` | `""` | Extra Tailwind classes |

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
