Reference
Router
Where the current page renders. May sit at any depth inside app; pages declare their own paths.
Router(transition: Enum, duration: String) { … }
Before 5.0
transition
none
fade
slide
No preview for this one: the example below shows how it is written.
Example
Stack {
Navbar {
Navbar.Brand { Link("Ledger", to: "/") }
Navbar.Links {
Link("Learn", to: "/learn")
Link("Reference", to: "/reference")
}
}
Router(transition: .fade, duration: "200ms")
Text("© 2026 Ledger").muted.sm
}
Beside a sidebar, pages that slide
Row {
Sidebar {
Sidebar.Item(to: "/learn", icon: "book") { Text("Learn") }
Sidebar.Item(to: "/recipes", icon: "list") { Text("Recipes") }
}
Container { Router(transition: .slide, duration: "250ms") }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
transition: | one of its cases | none | How a route change moves between pages, through the browser's View Transitions where it has them; none for a reader who asks for less motion. Written as a flag,
|
duration: | String |
| How long each half of the transition plays, a CSS time, |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.none
.fade
.slide
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Renders with the class wf-router, stable across releases, so a stylesheet may target it.
Codes this can raise
These controls list the props' cases; the example below shows them written.