1. Home
  2. /
  3. Seed-rust
  4. /
  5. Seed Component with Input Binding

Seed Component with Input Binding - Seed-rust Typing CST Test

Loading…

Seed Component with Input Binding — Seed-rust Code

Binds input value to model state.

# seed/demo/input.rs
use seed::{prelude::*, *};

struct Model { text: String }

enum Msg { Update(String) }

fn init(_: Url, _: &mut Orders<Msg>) -> Model {
	Model { text: String::new() }
}

fn update(msg: Msg, model: &mut Model, _: &mut Orders<Msg>) {
	if let Msg::Update(value) = msg {
		model.text = value
	}
}

fn view(model: &Model) -> Node<Msg> {
	div![
		input![
		type_("text"),
		attrs! { At::Value => model.text },
		ev(Ev::Input, |e| Msg::Update(e.value))
		],
		p![&model.text]
	]
}

#[wasm_bindgen(start)]
pub fn start() {
	App::start("app", init, update, view);
}

Seed-rust Language Guide

Seed is a Rust framework for creating front-end web apps with WebAssembly. It provides a component-based architecture inspired by Elm, enabling Rust developers to write type-safe, reactive web applications that compile to Wasm.

Primary Use Cases

  • ▸Single-page web applications (SPAs) in Rust
  • ▸High-performance dashboards and visualizations
  • ▸Interactive web games
  • ▸Wasm modules for web apps with Rust logic
  • ▸Integration-heavy front-end apps needing Rust crates

Notable Features

  • ▸Component-based architecture similar to Elm
  • ▸Virtual DOM for efficient UI updates
  • ▸Reactive message-driven state management
  • ▸Rust-to-Wasm compilation for high performance
  • ▸Works with wasm-bindgen to access JS and Web APIs

Origin & Creator

Seed was created by IcedDev and the Rust community, first appearing around 2018.

Industrial Note

Seed-Rust is ideal for developers who want Rust’s safety and performance for front-end web apps, especially for Wasm-based projects where speed and correctness are critical.

More Seed-rust Typing Exercises

Simple Seed ComponentSeed Component with ButtonSeed Counter ComponentSeed Todo ListSeed Component with Conditional RenderingSeed List RenderingSeed Component with Click CounterSeed Component with Multiple Elements

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher