Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Displays different lists based on a toggle signal.
# sycamore/demo/conditional_loop.rs
use sycamore::prelude::*;
fn app<G: Html>() -> View<G> {
let show_first = create_signal(true);
let list1 = vec!["A", "B", "C"];
let list2 = vec!["X", "Y", "Z"];
view! {
div {
button(on:click=move |_| show_first.set(!*show_first.get())) {"Toggle"}
(if *show_first.get() {
view! { Keyed(list1, |i| i.clone(), |i| view! { p { (i) } }) }
} else {
view! { Keyed(list2, |i| i.clone(), |i| view! { p { (i) } }) }
})
}
}
}
fn main() {
sycamore::render(app);
}Sycamore is a reactive, component-based web framework for Rust that allows developers to build fast, type-safe web applications with a declarative approach similar to React or Solid.js.
Origin & Creator
Sycamore was created by Austin Donnelly and contributors, inspired by modern reactive JavaScript frameworks but designed for Rust and WebAssembly.
Industrial Note
Sycamore is ideal for Rust developers who want high-performance, type-safe web apps without leaving the Rust ecosystem, and for projects where predictable memory management and performance are critical.