---
title: "Checkbox"
description: "A single checkbox, for consent or one yes/no setting."
---

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

# Checkbox

```gistui
root = Form("consent", Checkbox("terms", "I accept the terms", required), Checkbox("news", "Send me product news", checked))
```

## Signature

This is the line a model reads in the system prompt.

```gistui
Checkbox(name, label, bind:$var, error:str, checked, required)
```

- **Group:** Forms
- **Children:** No
- **Positional arguments:** `name`, `label` (a trailing `?` means it may be left out)

## Props

| Prop | Type | How to write it | Notes |
|---|---|---|---|
| `name` | string | positional, required |  |
| `label` | string | positional, required |  |
| `bind` | `$state` variable | `bind:$name` | two-way binding to a $variable |
| `checked` | flag | bare word: `checked` |  |
| `required` | flag | bare word: `required` |  |
| `error` | string | named: `error:…` |  |

## Use your own component

Keep the name and schema, swap what is drawn. The prompt and the model's output do not change.

### React

```tsx
import { ui } from "@gistui/react/ui";

const lib = ui.extend({ Checkbox: MyCheckbox });
<GistUI library={lib} stream={response.body} />;
```
### Vue

```vue
<GistUI :source="answer" :components="{ Checkbox: MyCheckbox }" />
```
### Svelte

```svelte
<GistUI source={answer} components={{ Checkbox: MyCheckbox }} />
```
### Solid

```tsx
<GistUI source={answer()} components={{ Checkbox: MyCheckbox }} />
```
### Vanilla

```ts
import { ui } from "@gistui/vanilla/ui";

const lib = ui.extend({ Checkbox: (ctx) => ({ el: myElement(ctx) }) });
```

See [Custom components](/docs/guides/custom-components/) for the full contract. Style hook: `[data-gistui="Checkbox"]`.

Source: https://gistui.com/docs/components/forms/checkbox/index.mdx
