# Toggle

> Toggle is an on/off setting drawn as a vanilla button that reads ON or OFF after its label, like the toggles on the game's options screens.

URL: https://xichil.dev/docs/xis-mvui/v1/widgets/toggle/ · Updated: 2026-11-06 · Applies to: Fabric, Quilt, Legacy Fabric, Forge, NeoForge, MC 1.7.10 - 26.3

An on/off setting, drawn as a vanilla button reading "label: ON" or "label: OFF", like the toggles on vanilla's
options screens. A click flips it.

```java
Toggle.builder("particles")
        .label(Text.translatable("mymod.particles", "Particles"))
        .value(() -> config.particles)
        .onChange(on -> config.particles = on)
        .build();
```

## Builder

| Method | Required | Default | Notes |
| --- | --- | --- | --- |
| `label(Supplier<Text>)` / `label(Text)` | yes | | the text before ": ON/OFF" |
| `value(BooleanSupplier)` | yes | | reads your current value; re-read on every refresh |
| `onChange(Consumer<Boolean>)` | yes | | stores the new value; main thread |
| `enabled`, `tooltip`, `visible` | no | | [options every widget has](https://xichil.dev/docs/xis-mvui/v1/widgets/index.md#options-every-widget-has) |

## Behaviour

- A click calls `onChange` with the opposite of `value`. The toggle shows the new value only if `value` returns
  it afterwards ([State and refresh](https://xichil.dev/docs/xis-mvui/v1/concepts/state-and-refresh/index.md)).
- "ON" and "OFF" are vanilla's `options.on` and `options.off`, so they're translated in every language.
- For a list of independent choices, use a [Checkbox](https://xichil.dev/docs/xis-mvui/v1/widgets/checkbox/index.md): the same value, drawn as a check box.
- **Footer:** yes.

## Test it

```java
host.click("particles");               // flips it
```

Rendered as `[toggle particles] Particles: ON`.

## See also

- Javadoc: [Toggle](https://xichil.dev/javadoc/xis-mvui/v1/dev/xichil/mvui/Toggle.html)
