Rune-Web guide
Styles and responsive layout
Give a reading shelf a responsive grid using @Style tokens, presets and rules. The entire presentation is authored in Rune.
i18n.Guide.syntax
tokens: names shared values; presets: groups reusable declarations. .panel uses the panel preset, and style = guide attaches the named style to the page.
Selector rules include focus-visible states and a grid that fits the available width. Token references such as brand keep colors consistent. These are styling declarations, not reactive application state.
Resize the preview or your browser. Open parts/style.rune below, change the brand token, and export locally to try your own palette.
Run this lesson locally
cargo run -- examples/rune-web/guide/styling.rune
cargo run -- examples/rune-web/guide/styling.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.
Styles and responsive layout
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.
styling.rune
#!RUNE
# Inspect parts/style.rune for tokens, presets, selector rules and a fluid grid.
import "parts/style.rune"
@App
name = Responsive reading shelf
type = REST
@Frontend
type = rune-web
path = %ROOT%
page = shelf
@Page/shelf
title = Responsive reading shelf
style = guide
view:
main:
h1 "A little reading shelf"
p "Resize the preview: these cards flow into the space available."
div .grid:
article .panel:
h2 "Discover"
p "Start with a small Rune document."
article .panel:
h2 "Build"
p "Compose a page from reusable pieces."
article .panel:
h2 "Share"
p "Export your page and let someone try it."
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