> For the complete documentation index, see [llms.txt](https://vue-generators.gitbook.io/vue-generators/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vue-generators.gitbook.io/vue-generators/fields/optional_fields/switch.md).

# switch

This is a switch/toogle input field for any values. It can toggle true/false, yes/no, on/off values.

## Special properties of field

| Property   | Default | Accepted values            | Description                              |
| ---------- | ------- | -------------------------- | ---------------------------------------- |
| `textOn`   | *none*  | `String`                   | Visible label if the switch state is on  |
| `textOff`  | *none*  | `String`                   | Visible label if the switch state is off |
| `valueOn`  | *none*  | any primitives or `Object` | Value if the switch state is on          |
| `valueOff` | *none*  | any primitives or `Object` | Value if the switch state is off         |

## Usage

Simple example with active/inactive labels

```javascript
{
    type: "switch",
    label: "Status (switch field)",
    model: "status",
    textOn: "Active",
    textOff: "Inactive"
}
```

Example with male/female model values

```javascript
{
    type: "switch",
    label: "Sex",
    model: "sex",
    textOn: "Female",
    textOff: "Male",
    valueOn: "female",
    valueOff: "male"
}
```
