Reference
Link
Client-side navigation link; its label or its block is the link text.
Link(_ label: String, to: Path, active: Enum) { … }
Before 5.0
label
active
prefix
Example
Stack(gap: .sm) {
Link("Start the guide", to: "/learn")
Link("Every component", to: "/reference", active: .prefix)
Link(to: "/recipes") {
Icon("book")
Text("Recipes for common screens")
}
Link("The source on GitHub", to: "https://github.com/webfluent/webfluent", target: "_blank")
}
Active on every route beneath it
Link("Reference", to: "/reference").prefix
To a filtered view: active only with its query
Link("Open", to: "/reference?show=open")
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
label | String (positional) | none | The link's words; a block written after it may be its content instead |
to: | Path | none | The route or address it goes to, navigated in place; while it matches the current route the link carries |
active: | one of its cases | exact match | How it decides it is the current page: unset, the route must equal
|
Attribute families: global, aria, data, anchor. 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.
.prefix
Events
The DOM events it is drawn to answer. Any other DOM event works too, in an on … { } handler.
| Event | Sends | Meaning |
|---|---|---|
on click | DOM | The element was clicked or activated |
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Renders with the class wf-link, stable across releases, so a stylesheet may target it.