Crate edom

source ·
Expand description

An immediate mode web frontend library written in Rust.

It builds up VDOM for not having to run too many DOM operations, but as it runs every time any change is executed, it allows for a simple programming model without message passing / callbacks / signals, just like EGUI.

The render function is called once for creating the initial web page, and then twice for each event:

  • once for computing the side effects of the event
  • once more for rendering the changes that happened by modifying the state (variables)

A very simple program to illustrate usage

(in examples/demo directory):

use edom;
use wasm_bindgen::prelude::wasm_bindgen;

pub fn demo() {
    let mut name = "Arthur".to_string();
    let mut age:f64 = 42.0;
    edom::wasm::render(move |mut root| {
        root.h1().text("My edom application");
        root.div(|div| {
            div.text("Your name: ");
            div.text_input(&mut name);
        root.div(|div| {
            div.range_input(&mut age, 0.0, 120.0);
            div.number_input(&mut age).min(0.0).max(120.0);
        if root.button("Click each year").clicked() {
        root.text(format!("Hello '{}', age {}", name, age).as_str());

The web page looks like this:



pub use dom::EventHandler;
pub use dom::Document;
pub use visitor::Visitor;
pub use dom::ElementNode;


An abstraction for DOM operations (collection of traits)
A no-operation implementation of dom operations for testing and outputting HTML.
A virtual DOM that is created for only calling the necessary dom operations.
Visitor pattern for building / visiting entries of vdom and doing dom manipulations.
Functions for manipulations that are specific to HTML in the visitor.
An implementation of dom traits using wasm-bindgen


Main structure for building and rendering a vdom tree and running the event loop.