> For the complete documentation index, see [llms.txt](https://nour-eldin-shobier.gitbook.io/carbon-flutter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nour-eldin-shobier.gitbook.io/carbon-flutter/widgets/toggle.md).

# Toggle

## Overview

A toggle is used to quickly switch between two possible states. They are commonly used for “on/off” switches.

![](https://2985180403-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhSQqKqKx7I7rVBbqF_%2F-MhSeF0jNW5ZlNOTO2W5%2F-MhSeL5tL3jUOTKdKVTO%2Fimage.png?alt=media\&token=8416126d-1876-4a50-a516-a190d931fb64)

### Widget API

| Property        | Description                                                                                                                                                                                                                                               |                                                                                                                                             |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| onToggle        | <p>Called when the value of the toggle change. This callback passes the new value, but doesn't update its state internally.</p><ul><li><strong>Type:</strong> <code>void Function(bool value)</code></li><li><strong>Default:</strong> required</li></ul> |                                                                                                                                             |
| enable          | <p>Whether the toggle is enabled or not.</p><ul><li><strong>Type:</strong> <code>bool</code></li><li><strong>Default:</strong> <code>true</code></li></ul>                                                                                                |                                                                                                                                             |
| value           | <p>Whether the initial value of the toggle is checked or not.</p><ul><li><strong>Type:</strong> <code>bool</code></li><li><strong>Default:</strong> <code>true</code></li></ul>                                                                           |                                                                                                                                             |
| labelText       | <p>The <code>labelText</code> of this toggle.</p><ul><li><strong>Type:</strong> <code>String?</code></li><li><strong>Default:</strong> optional</li></ul>                                                                                                 |                                                                                                                                             |
| size            | <p>The size of this toggle. It can be <code>md</code> or <code>sm.</code></p><ul><li><strong>Type:</strong> <code>CToggleSize</code></li><li><strong>Default:</strong> <code>CToggleSize.md</code></li></ul>                                              |                                                                                                                                             |
| showStatusLabel | <p>Whether the toggle should display its status (<code>On</code>                                                                                                                                                                                          | <code>Off</code>) or not.</p><ul><li><strong>Type:</strong> <code>bool</code></li><li><strong>Default:</strong> <code>true</code></li></ul> |

### Example

```dart
CToggle(
  onToggle: (v) {},
  value: true,
  labelText: 'Label text',
  showStatusLabel: true,
  size: CToggleSize.sm,
)
```
