Coming from
WebFluent for HTML and CSS authors
If you write HTML and CSS by hand, WebFluent keeps what you know and takes away the repetition: elements come designed and accessible, a page's head is written for you, and a layout is a `Row` or a `Grid` instead of a class and a rule. Your CSS still works — any `.css` file under `src/` is part of the build.
A page
You write
index.html with <head>, <title> and <body>
In WebFluent
page Home(path: "/", title: "Home", description: "…") { … }
A heading
You write
<h1>Welcome</h1>
In WebFluent
Heading("Welcome").h1
A paragraph
You write
<p>Hello</p>
In WebFluent
Text("Hello")
A link
You write
<a href="/about">About</a>
In WebFluent
Link("About", to: "/about")
A picture
You write
<img src="/team.jpg" alt="The team">
In WebFluent
Image(src: "/team.jpg", alt: "The team")
A button
You write
<button class="btn btn-primary">Save</button>
In WebFluent
Button("Save").primary
A list
You write
<ul><li>One</li></ul>
In WebFluent
List { List.Item { Text("One") } }
A table
You write
<table><thead>…</thead><tbody>…</tbody></table>
In WebFluent
Table { Table.Head { … } Table.Body { … } }
A form field
You write
<label for="e">Email</label><input id="e" type="email">
In WebFluent
Input(bind: email, label: "Email").email
A row with flexbox
You write
<div class="row"> and .row { display: flex; gap: 16px }
In WebFluent
Row(gap: .md) { … }
A grid
You write
.grid { display: grid; grid-template-columns: repeat(3, 1fr) }
In WebFluent
Grid(columns: 3, gap: .md) { … }
A responsive grid
You write
a @media rule per breakpoint
In WebFluent
Grid(columns: { base: 1, md: 3 })
Inline styles
You write
style="padding: 2rem"
In WebFluent
style { padding: 2rem } in the element's block
Hover and focus
You write
.card:hover { … }
In WebFluent
style { &:hover { … } }
A stylesheet
You write
<link rel="stylesheet" href="site.css">
In WebFluent
any .css file under src/
CSS variables
You write
--brand: #0F766E and var(--brand)
In WebFluent
a theme of design tokens, read as $color-primary
Dark mode
You write
@media (prefers-color-scheme: dark)
In WebFluent
a second theme, named as "dark" in the config
A script
You write
<script src="app.js"></script>
In WebFluent
a plain .js file under src/, its functions called by name
Meta tags
You write
<meta name="description">, Open Graph tags
In WebFluent
the page's title: and description:, and meta in the config
Things that work differently
Elements are checked. An Image with no alt: is a warning (A01), a Link to a page that does not exist is an error (R01), and a flag the element does not have (Button("Save").primray) stops the build. What you would have caught with a validator and an accessibility audit, the compiler catches on every build.
Text is text. Every string goes in as text, so a < in it is shown, not parsed. Markup you did not write goes through Unsafe.Html(sanitize(…)), which the build reports each time; inline onclick handlers do not compile — a handler is on click { … } in the element's block.
The head is written for you. Each page's title, description, canonical link, Open Graph and Twitter tags, structured data, a sitemap and robots.txt come from the page and the config (Describe pages to search engines and link previews).
Your CSS is welcome, scoped by you. A .css file under src/ is bundled after the built-ins' rules, so yours win; class: on any element adds your classes. A style { } block is for the one element it is on.
A site, not a pile of files. Pages share a header and footer through app (or a layout:), a value shared by pages is a store, and repeated markup is a component with typed props.
A component, ported
A card that shows a person, in HTML and CSS and in WebFluent.
<div class="card">
<img class="avatar" src="/ada.jpg" alt="Ada Lovelace">
<div>
<h2>Ada Lovelace</h2>
<p class="muted">Analyst</p>
</div>
</div>
<style>
.card { display: flex; gap: 12px; align-items: center; padding: 16px;
border: 1px solid #ddd; border-radius: 8px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; }
.muted { color: #666; }
</style>
page Team(path: "/", title: "Team", description: "Who we are.") {
Heading("Team").h1
Person("Ada Lovelace", role: "Analyst", photo: "/ada.jpg")
}
component Person(_ name: String, role: String, photo: String) {
Card.outlined {
Row(gap: .sm, align: .center) {
Avatar(src: photo, alt: name)
Stack {
Heading(name).h2
Text(role).muted
}
}
}
}
- No class names to invent.
Card.outlined,Avatarand.mutedcome designed, and follow the theme. - One component, many people.
Personis placed with each person's props; the compiler checks every call.