Interactive Gallery · 12 Live WasmGC Islands + 3D & 2D Build-Time Plots

Examples

Every interactive widget below runs compiled Julia via WasmTarget.jl (WasmGC). Expand any section to inspect its source, or browse docs/src/components.

Interactive 3D Surface

WasmMakie Axis3 · @island

Pure-Julia 3D WasmMakie.Axis3 with a z-buffered Blinn-Phong triangle rasterizer (surface! + wireframe! + Colorbar) compiled to WasmGC via WasmMakieTherapyExt. Drag directly on the canvas to orbit or scroll to zoom — zero WebGL, zero Three.js.

Drag to orbit · Scroll to zoom
az230
el24
zoom100
View Julia source
import WasmMakie as WM
using WasmMakie: surface!, wireframe!

@island hydrate = :visible function Orbit3DShowcase()
    az_deg, set_az_deg = create_signal(Int64(230))
    el_deg, set_el_deg = create_signal(Int64(24))
    zoom_pct, set_zoom_pct = create_signal(Int64(100))

    create_effect(() -> begin
        fig = WM.Figure(size = (880.0, 480.0))
        ax = WM.Axis3(fig[1, 1];
            azimuth = Float64(az_deg()) * pi / 180,
            elevation = Float64(el_deg()) * pi / 180,
            zoom_mult = Float64(zoom_pct()) / 100.0,
        )
        sf = surface!(ax, xs, ys, zs, nx, ny; colormap = :viridis)
        wireframe!(ax, xs, ys, zs, nx, ny; color = (0.0, 0.0, 0.0, 0.22))
        WM.Colorbar(fig[1, 2], sf; label = "Amplitude")
        WM.render!(fig, WM.WasmCtx())
    end)
    ...
end
SSR · zero Wasm

WasmMakie plots rendered at build time through html_snippet(fig): a canvas, recorded Canvas2D commands, and a lightweight replayer. Zero WebAssembly, zero hydration.

Axis3 · surface!3D Blinn-Phong + wireframe
Axis3 · Lorenz 3Dlines! + scatter! + Colorbar
lines!two waves, cycled colors
scatter!markers and sizes
barplot!categorical bars
heatmap! + Colorbarflat grid, viridis
band!shaded interval
density!kernel density

Plot Dashboard

WasmMakie · @island

One WasmMakie.Figure with four Axis subplots (lines!, scatter!, barplot!, heatmap!) driven together by freq, n_pts, and shift.

freq3
n_pts12
shift0
View Julia source
import WasmMakie as WM
using WasmMakie: lines!, scatter!, barplot!, heatmap!

@island function InteractivePlotDashboard()
    freq, set_freq = create_signal(Int64(3))
    n_pts, set_n_pts = create_signal(Int64(12))
    shift, set_shift = create_signal(Int64(0))

    create_effect(
        () -> begin
            f = Float64(freq())
            n = n_pts()
            sh = shift()
            phase = Float64(sh) * 0.5

            fig = WM.Figure(size = (1000.0, 560.0))

            ax_ln = WM.Axis(fig[1, 1]; title = "lines!", subtitle = "freq + n_pts")
            xs = [Float64(i) / Float64(n * 12) * 6.28318 for i in 1:(n * 12)]
            ys = [sin(x * f) for x in xs]
            lines!(ax_ln, xs, ys; color = :blue, linewidth = 2.0)

            ax_sc = WM.Axis(fig[1, 2]; title = "scatter!", subtitle = "n_pts")
            sx = [Float64(i) for i in 1:n]
            sy = [cos(Float64(i) * 0.6) * 4.0 + 5.0 for i in 1:n]
            scatter!(ax_sc, sx, sy; color = :red, markersize = 8.0)

            ax_bp = WM.Axis(fig[2, 1]; title = "barplot!", subtitle = "shift")
            base = Float64[3.0, 7.0, 2.0, 5.0, 8.0, 4.0, 6.0]
            nb = length(base)
            hs = [base[mod(k - 1 + sh, nb) + 1] for k in 1:nb]
            barplot!(ax_bp, Float64[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0], hs; color = :green)

            ax_hm = WM.Axis(fig[2, 2]; title = "heatmap!", subtitle = "freq + shift")
            vals = Float64[]
            for col in 0:11
                for row in 0:19
                    x = Float64(row) / 20.0 * 6.28318
                    y = Float64(col) / 12.0 * 6.28318
                    push!(vals, sin(x * f + phase) * cos(y * f))
                end
            end
            heatmap!(ax_hm, 20, 12, vals)

            WM.render!(fig, WM.WasmCtx())
        end,
    )

    return Div(
        Canvas(:width => 1000, :height => 560),
        Button(:on_click => () -> set_freq(freq() + Int64(1)), "freq +"),
        Button(:on_click => () -> set_n_pts(n_pts() + Int64(4)), "points +"),
        Button(:on_click => () -> set_shift(shift() + Int64(1)), "shift +"),
    )
end

Counter

signal + memo + effect

Fine-grained signals, a cached create_memo, and an effect streaming updates to console.log.

0
doubled 0
View Julia source
@island function InteractiveCounter(; initial::Int = 0)
    count, set_count = create_signal(initial)
    doubled = create_memo(() -> count() * 2)
    create_effect(
        () -> js(
            "console.log('count:', \$1, 'doubled:', \$2)",
            count(),
            doubled(),
        ),
    )

    return Div(
        Button(:on_click => () -> set_count(count() - 1), "-"),
        Span(count),
        Button(:on_click => () -> set_count(count() + 1), "+"),
        Span("doubled ", Span(doubled)),
    )
end

Dark Mode Toggle

shared signal

Cross-island state sharing: this toggle and the navbar toggle are independent @island modules subscribed to the same module-level dark_mode signal.

Toggle site theme →
View Julia source
const dark_mode = create_signal(0)

@island function DarkModeToggle()
    is_dark, set_dark = dark_mode
    js("if(document.documentElement.classList.contains('dark'))\$1(1)", set_dark)

    return Button(
        :on_click =>
            () -> begin
                set_dark(1 - is_dark())
                js("document.documentElement.classList.toggle('dark')")
                js(
                    "localStorage.setItem('therapy-theme', document.documentElement.classList.contains('dark') ? 'dark' : 'light')",
                )
            end,
        "Toggle",
    )
end
WasmGC String signal

String signal stored as a WasmGC reference global; on each keystroke a reactive memo filters items with lowercase and startswith inside WebAssembly.

37 languages
Julia
Python
Rust
Go
JavaScript
TypeScript
Haskell
Elixir
Ruby
Swift
Kotlin
Scala
View Julia source
@island function SearchableList(;
    items_data::Vector{String} = String[],
    visible_init::Int = 12,
)
    query, set_query = create_signal("")
    visible_count, set_visible_count = create_signal(visible_init)
    total_count, _ = create_signal(length(items_data))

    visible_items = create_memo(
        () -> begin
            q = lowercase(query())
            n = visible_count()
            filtered = String[]
            for i in 1:length(items_data)
                if length(q) == 0 || startswith(lowercase(items_data[i]), q)
                    push!(filtered, items_data[i])
                end
            end
            result = String[]
            for i in 1:min(n, length(filtered))
                push!(result, filtered[i])
            end
            result
        end,
    )

    return Div(
        Input(:type => "text", :on_input => set_query),
        For(visible_items) do item
            Div(item)
        end,
        Show(() -> visible_count() < total_count()) do
            Button(:on_click => () -> set_visible_count(visible_count() + 12), "show more")
        end,
    )
end

Todo List

For + Show + disposal

Keyed list rendering with For() backed by a Vector{String} memo, disposing item owners automatically as rows are removed.

Todos

5 / 5
Buy milk
Write Julia code
Ship to production
Review PR
Fix tests

Click 'Remove last' to shrink the list and dispose item owners.

View Julia source
@island function TodoList(; items_data::Vector{String} = String[])
    remaining, set_remaining = create_signal(length(items_data))
    total, _ = create_signal(length(items_data))

    visible = create_memo(
        () -> begin
            n = remaining()
            result = String[]
            for i in 1:min(n, length(items_data))
                push!(result, items_data[i])
            end
            result
        end,
    )

    return Div(
        Span(remaining, " / $(length(items_data))"),
        For(visible) do item
            Div(Span(item))
        end,
        Show(() -> remaining() > 0) do
            Button(:on_click => () -> set_remaining(remaining() - 1), "Remove last")
        end,
        Show(() -> remaining() < total()) do
            Button(:on_click => () -> set_remaining(remaining() + 1), "Add back")
        end,
    )
end

Show / Fallback

conditional DOM

Conditional rendering with Show() and a fallback branch that mounts and unmounts real DOM subtrees.

Mounted in the DOM right now

Inspect this element: clicking Toggle removes these nodes and swaps in the fallback branch.

Content is hidden. Click Toggle to restore it.

Rendered via the fallback prop while the condition is false.

View Julia source
@island function ShowDemo(; initial_visible::Int = 1)
    visible, set_visible = create_signal(initial_visible)
    create_effect(() -> js("console.log('ShowDemo visible:', \$1)", visible()))

    return Div(
        Button(:on_click => () -> set_visible(1 - visible()), "Toggle Content"),
        Show(visible; fallback = P("Content is hidden.")) do
            P("Mounted in the DOM right now.")
        end,
    )
end

Mount vs Effect Lifecycle

on_mount + create_effect

on_mount executes once after hydration, while create_effect re-runs on every tracked signal update.

count: 0

Open the console (F12): on_mount logs once on hydration, while create_effect logs on every click.

View Julia source
@island function MountDemo()
    count, set_count = create_signal(0)
    on_mount(() -> js("console.log('on_mount: I ran once!')"))
    create_effect(
        () -> js("console.log('create_effect: count is', \$1)", count()),
    )

    return Div(
        Button(:on_click => () -> set_count(count() + 1), "Click me"),
        P("count: ", count),
    )
end

Auto-Batching

batched handlers

Event handlers batch multiple signal writes automatically so dependent effects flush once.

a=0 b=0

Open the browser console: each click logs one effect, not two.

View Julia source
@island function BatchDemo()
    a, set_a = create_signal(0)
    b, set_b = create_signal(0)
    create_effect(
        () -> js(
            "console.log('effect: a=', \$1, 'b=', \$2)",
            a(),
            b(),
        ),
    )

    return Div(
        P("a=", Span(a), "  b=", Span(b)),
        Button(
            :on_click =>
                () -> begin
                    set_a(a() + 1)
                    set_b(b() + 10)
                end,
            "Increment both",
        ),
        Button(
            :on_click =>
                () -> begin
                    set_a(0)
                    set_b(0)
                end,
            "Reset",
        ),
    )
end

Signal Types

Int64 · Bool · Float64 · String

Four native WebAssembly signal types: Int64 (i64), Bool (i32), Float64 (f64), and String (WasmGC ref).

Int64
0
Bool
Float64
98.6
String
View Julia source
@island function SignalTypesDemo()
    count, set_count = create_signal(0)       # Int64   -> i64
    active, set_active = create_signal(false) # Bool    -> i32
    temp, set_temp = create_signal(98.6)      # Float64 -> f64
    name, set_name = create_signal("")        # String  -> WasmGC ref

    create_effect(
        () -> js(
            "console.log('signals:', \$1, \$2, \$3, \$4)",
            count(),
            active(),
            temp(),
            name(),
        ),
    )

    return Div(
        Button(:on_click => () -> set_count(count() + 1), "+"),
        Button(:on_click => () -> set_active(!active()), Span(active)),
        Button(:on_click => () -> set_temp(temp() + 1.0), "+"),
        Input(:type => "text", :on_input => set_name),
    )
end

Data Table

SSR + WasmGC sorting

Two-tier SSR + @island architecture: DataTable() prepares column vectors on the server and DataExplorer() sorts row indices in WasmGC. Click any header to sort.

NameAgeScoreCity
Alice2895.2Portland
Bob3587.1Austin
Carol4291.8Denver
Dave2378.4Seattle
Eve3193.6Boston
Frank4582.3Chicago
Grace2796.1Miami
Heidi3388.5Phoenix
Ivan2990.3Dallas
Judy3884.7Atlanta
View Julia source
# Tier 1: SSR prepares column vectors with full Julia access
function DataTable()
    names = ["Alice", "Bob", "Carol", "Dave", "Eve", "Frank"]
    ages = ["28", "35", "42", "23", "31", "45"]
    scores = ["95.2", "87.1", "91.8", "78.4", "93.6", "82.3"]
    cities = ["Portland", "Austin", "Denver", "Seattle", "Boston", "Chicago"]
    return DataExplorer(
        col_names = names,
        col_ages = ages,
        col_scores = scores,
        col_cities = cities,
    )
end

# Tier 2: @island sorts and paginates indices inside WasmGC
@island function DataExplorer(;
    col_names::Vector{String} = String[],
    col_ages::Vector{String} = String[],
    col_scores::Vector{String} = String[],
    col_cities::Vector{String} = String[],
)
    visible_count, set_visible_count = create_signal(10)
    sort_col, set_sort_col = create_signal(0)

    visible_indices = create_memo(
        () -> begin
            c = sort_col()
            n = visible_count()
            indices = Int64[Int64(i) for i in 1:length(col_names)]
            col = c == 2 || c == -2 ?
                col_ages :
                c == 3 || c == -3 ? col_scores : c == 4 || c == -4 ? col_cities : col_names
            if c != 0
                for ii in 2:length(indices)
                    key_idx = indices[ii]
                    jj = ii - 1
                    while jj >= 1
                        ordered = c > 0 ?
                            isless(col[indices[jj]], col[key_idx]) :
                            isless(col[key_idx], col[indices[jj]])
                        ordered && break
                        indices[jj + 1] = indices[jj]
                        jj -= 1
                    end
                    indices[jj + 1] = key_idx
                end
            end
            indices[1:min(n, length(indices))]
        end,
    )

    toggle_sort(col_id::Int) = set_sort_col(sort_col() == col_id ? -col_id : col_id)

    return Div(Table(
        Thead(Tr(
            Th(:on_click => () -> toggle_sort(1), "Name"),
            Th(:on_click => () -> toggle_sort(2), "Age"),
            Th(:on_click => () -> toggle_sort(3), "Score"),
            Th(:on_click => () -> toggle_sort(4), "City"),
        )),
        Tbody(
            For(visible_indices) do idx
                Tr(
                    Td(col_names[idx]),
                    Td(col_ages[idx]),
                    Td(col_scores[idx]),
                    Td(col_cities[idx]),
                )
            end,
        ),
    ))
end