RavenRS · Rust GUI

ButtonGroup

Edit and run the ButtonGroup RavenRS example in your browser. Explore its Rust code and download a Cargo project for desktop and WebAssembly.

One declarative Rust interface, GPU rendering, reactive state and semantic design tokens. Free and open source under MIT OR Apache-2.0.

Rust source

fn button_group() -> impl View {
    let period = State::new(0);
    view_fn(move || {
        let chosen = period.get();
        let item = |index, label: &str| {
            let period = period.clone();
            let style = if chosen == index { ButtonStyle::Primary } else { ButtonStyle::Secondary };
            Button::new(label).style(style).on_click(move || period.set(index))
        };
        ButtonGroup::new([item(0, "Day"), item(1, "Week"), item(2, "Month")]).label("Period")
    })
}

The interactive preview loads when JavaScript and WebGPU or WebGL2 are available. You can read the guide and examples here at any time.

More examples