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

# Input Boolean

> Asks a yes or no question with a checkbox.

`io.input.boolean()` asks a yes or no question and returns `true` or `false`. Provided by the `@awaitio/input-boolean` package.

<Frame>
  <img src="https://mintcdn.com/awaitio/MjbT5AW66vMXbVck/images/io-input-boolean.png?fit=max&auto=format&n=MjbT5AW66vMXbVck&q=85&s=dfd777e9fb7b67cff076c8f94b258ca6" alt="The label Send a confirmation email above a checked checkbox with the help text to its right" width="1004" height="136" data-path="images/io-input-boolean.png" />
</Frame>

## Install

```bash theme={null}
npm install @awaitio/input-boolean
```

## Setup

Register it under the key you want in `io`, see [Input components](/core/components):

```ts app.ts {5} theme={null}
import { inputBoolean } from '@awaitio/input-boolean';

export const app = new AwaitIO({
  // name, actionsDirectory, theme, secret, users…
  components: { input: { boolean: inputBoolean } },
});
```

## Usage

```ts theme={null}
const sendEmail = await io.input.boolean('Send a confirmation email', {
  defaultValue: true,
  helpText: 'The customer gets a copy of the change',
});
```

## Props

| Prop | Type | Required | Description |
| - | - | - | - |
| `helpText` | `string` | Required | Shown to the right of the checkbox: what checking it means. |
| `defaultValue` | `boolean` | Optional | Whether the box starts checked. Defaults to `false`. |
| `disabled` | `boolean` | Optional | Shows the starting value without letting it change; the handler gets that value whatever the browser sends. |

## Returns

`boolean`: `true` when the box is checked, `false` when it is not.

## Built-in validation

Nothing is checked: an unchecked box gives `false`.

## Custom validation

Chain `.validate()` for a check of your own. It runs on the server after the checks above, gets the value the handler would get and returns a message to show under the field, or nothing when the value is fine; see [Custom validation](/core/components#custom-validation).

```ts theme={null}
await io.input.boolean('I have read the refund policy').validate((isChecked) => {
  return isChecked ? undefined : 'Read the refund policy first.';
});
```


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