Rune-Web guide
Components and props
Compose a page from reusable @Component views. Workshop cards share a layout while their content comes from props.
i18n.Guide.syntax
props: [title, level, note?] declares required inputs and an optional note. Pass values by name at each component call; use ?? for a fallback.
@Frontend selects the @Page entry point. The page composes WorkshopCard twice; each instance receives its own prop values. Components are view reuse, not separate backend routes.
Compare the two cards and open their source. Give the first card a note, then run the app locally to see the override.
Run this lesson locally
cargo run -- examples/rune-web/guide/components.rune
cargo run -- examples/rune-web/guide/components.rune -o html > index.htmlEach 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.
Components and props
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
No matching files.
components.rune
#!RUNE
# Reuse one component with different props. No client state is needed.
import "parts/style.rune"
@App
name = Workshop cards
type = REST
@Frontend
type = rune-web
path = %ROOT%
page = workshops
@Component/WorkshopCard
props: [title, level, note?]
view:
article .panel:
h2 "{title}"
p "Level: {level}"
p .muted "{note ?? 'Bring your curiosity.'}"
@Page/workshops
title = Workshop cards
style = guide
view:
main:
h1 "Make something together"
div .grid:
WorkshopCard title="First Rune app" level="Beginner"
WorkshopCard title="Interface studio" level="Intermediate" note="Bring a small project."
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