Reference
Icon
One of the built-in SVG icons, rendered inline.
Icon(_ name: String, size: Enum, tone: Enum, muted: Bool)
Before 5.0
name
size
tone
Deployed
2 warnings
1 failed
Queued
Example
Row(gap: .lg, align: .center) {
Row(gap: .xs, align: .center) { Icon("check").success Text("Deployed") }
Row(gap: .xs, align: .center) { Icon("warning").warning Text("2 warnings") }
Row(gap: .xs, align: .center) { Icon("alert-circle").danger Text("1 failed") }
Row(gap: .xs, align: .center) { Icon("clock").muted Text("Queued") }
}
Sizes
Row(gap: .md, align: .center) {
Icon("star").sm
Icon("star")
Icon("star").lg.primary
}
Beside a button's words
Button("Download report") { Icon("download") Text("Download report") }
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
name | String (positional) | — | One of the 83 built-in icon names ( |
size: | one of its cases |
| How large it is, against the text around it. Written as a flag,
|
tone: | one of its cases | none: the text's colour | Its colour, a tone of the theme. Written as a flag,
|
muted: | Bool | false | In |
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.
.sm
.md
.lg
.primary
.secondary
.success
.danger
.warning
.info
.muted
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-icon, stable across releases, so a stylesheet may target it.