RavenRS · Rust GUI

ImageLightbox

Edit and run the ImageLightbox 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 image_lightbox() -> impl View {
    let open = State::new(None::<usize>);
    let opener = open.clone();
    let shades = [0.25_f32, 0.45, 0.65];
    let pictures = shades.into_iter().filter_map(|shade| {
        let image = ImageData::from_fn(320, 200, move |x, _| Color::rgb(shade, 0.3, x as f32 / 320.0))?;
        Some(LightboxItem::new(image).caption(format!("Shade {shade}")))
    });
    VStack::new((
        Button::new("Open pictures").on_click(move || opener.set(Some(0))),
        ImageLightbox::new(open.binding(), pictures),
    ))
}

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