Components / Toggle

Toggle

On/off switch.

Example

The component itself, running in WebAssembly, beside its code in a playground. Try it.

Code

use ravenrs::prelude::*;

fn toggle() -> impl View {
    let push = State::new(true);
    let email = State::new(false);
    VStack::new((
        Toggle::new(push.binding()).label("Push notifications"),
        Toggle::new(email.binding()).label("Email digest").small(),
    ))
    .spacing(12.0)
}

Open in the playground, with every example →

Full API of Toggle →