Components / Selection & input

Toggle

Markdown crates/ui/src/widgets/controls.rs docs.rs

Toggle

Ask your agent

Install the bezel skill once

npx skills add crabtalk/bezel --skill bezel

Then ask

Add a switch to the settings row that turns notifications on and off.
use ui::{focus, widgets::Controls};

focus::focusable(&theme, &self.switch, theme.toggle(self.enabled))
    .id("notifications")
    .on_click(cx.listener(|view, _, _, cx| view.flip(cx)))
    .on_action(cx.listener(|view, _: &focus::Activate, _, cx| view.flip(cx)))
  • Display-only: the caller holds the bool and wires the click and focus::Activate.