Early developmentPre-1.0: syntax may change.Release historyGitHub

Rune-Web guide

State and forms

Build a workshop pass whose preview follows your name and session. state: supplies the starting values; braces read them in text and attributes.

i18n.Guide.syntax

A change handler calls setGuest(this.value) or setSession(this.value). Named @Logic actions assign the new values, and the reactive runtime updates the view.

Change fires when a text edit is committed, such as leaving the field. This is explicit event handling; <-> is not a general input-value binding. The pass is a local preview and does not submit a reservation.

Change Guest to your name and leave the field. Choose Studio and watch both values appear on your pass.

Run this lesson locally

cargo run -- examples/rune-web/guide/forms.rune
cargo run -- examples/rune-web/guide/forms.rune -o html > index.html

Each example is a complete Rune-Web app and imports parts/style.rune. Open the source below to inspect both files. Demo data stays in this browser and resets when the preview reloads.

Live Rune-Web app

State and forms

This preview is compiled from the actual Rune example, including its styles and actions. Interact with the app, then explore its source files.

View source code
forms.rune
#!RUNE
# Explicit change events update state and the reservation preview.
import "parts/style.rune"
@App
name = Workshop RSVP
type = REST
@Frontend
type = rune-web
path = %ROOT%
page = rsvp
@Logic/rsvp
state:
    guest = "Guest"
    session = "Online"
action setGuest(value):
    guest = value
action setSession(value):
    session = value
@Page/rsvp
title = Workshop RSVP
style = guide
logic = rsvp
view:
    main:
        h1 "Your workshop pass"
        p "Edit your name, then leave the field to update the pass."
        label for=guest-name "Your name"
        input #guest-name type=text value="{guest}" change="setGuest(this.value)"
        label for=session "Session"
        select #session change="setSession(this.value)":
            option value=Online selected="{session == 'Online'}" "Online"
            option value=Studio selected="{session == 'Studio'}" "Studio"
        section .panel aria-live=polite:
            h2 "Welcome, {guest}"
            p "Session: {session}"
            p .muted "This is a local preview, not a booking service."
parts/style.rune
@Style/guide
tokens:
    brand = #166b73
    ink = #143841
    surface = #ffffff
    space = 1rem
presets:
    panel:
        background = {surface}
        border = 1px solid #c7e2e4
        border-radius = 16px
        padding = {space}
rules:
    body:
        margin = 0
        font-family = system-ui, sans-serif
        color = {ink}
        background = #edf7f7
    main:
        max-width = 900px
        margin = 0 auto
        padding = 1rem
    .grid:
        display = grid
        grid-template-columns = repeat(auto-fit, minmax(min(100%, 220px), 1fr))
        gap = {space}
    .panel:
        use = (panel)
        margin-bottom = 1rem
    .choices:
        display = flex
        flex-wrap = wrap
        gap = 0.5rem
        margin-bottom = 1rem
    button:
        padding = 0.75rem 1rem
        background = {brand}
        color = white
        border = 0
        border-radius = 8px
        cursor = pointer
        font = inherit
    button:focus-visible:
        outline = 3px solid #d56c45
        outline-offset = 3px
    button.active:
        background = #a94022
    input, select:
        display = block
        box-sizing = border-box
        width = 100%
        padding = 0.75rem
        margin = 0.5rem 0 1rem
        font = inherit
        border = 1px solid #8baeb3
        border-radius = 8px
    .muted:
        color = #44646b
    .done:
        text-decoration = line-through
    h1:
        font-size = clamp(1.5rem, 5vw, 2.2rem)
    p, li:
        line-height = 1.6
Built entirely with Rune-Web