---
url: /en/docs/fields/boolean.md
description: Select true/false values in Sveltia CMS using an intuitive toggle switch.
---

# Boolean Field

The Boolean field type allows users to select a true/false value using a toggle switch interface.

## User Interface

### Editor

A toggle switch. It can be turned on or off by clicking or tapping it, like a checkbox.

Additional text can be displayed before or after the switch using the `before_input` and `after_input` options.

### Preview

The preview shows the boolean value as `true` or `false`.

## Data Type

A boolean. If the `required` option is set to `false` and the field is left empty, the value will be `false`.

## Data Validation

No special validation is performed for Boolean fields as the value will always be either `true` or `false`.

## Options

In addition to the [common field options](/en/docs/fields#common-options), the Boolean field supports the following options:

### Required Options

#### `widget`

* **Type**: `string`
* **Default**: `string`

Must be set to `boolean`.

### Optional Options

#### `default`

* **Type**: `boolean`
* **Default**: `false`

The default value for the field when creating a new entry.

#### `before_input`

* **Type**: `string`
* **Default**: `""`

Text to display before the toggle switch. It’s placed at the `false` position.

#### `after_input`

* **Type**: `string`
* **Default**: `""`

Text to display after the toggle switch. It’s placed at the `true` position.

## Examples

### Basic Boolean Field

Configuration example:

::: code-group

```yaml [YAML]
- name: draft
  label: Draft
  widget: boolean
  default: true
```

```toml [TOML]
[[fields]]
name = "draft"
label = "Draft"
widget = "boolean"
default = true
```

```json [JSON]
{
  "name": "draft",
  "label": "Draft",
  "widget": "boolean",
  "default": true
}
```

```js [JavaScript]
{
  name: "draft",
  label: "Draft",
  widget: "boolean",
  default: true,
}
```

:::

Output example:

::: code-group

```yaml [YAML]
draft: true
```

```toml [TOML]
draft = true
```

```json [JSON]
{
  "draft": true
}
```

:::
