Reference
Highlight
Text with every match of query: marked (<mark>), as a search's results show what was found; the case is ignored.
Highlight(_ text: String, query: String)
Since 6.2.0
text
Example
state q = "state"
Stack(gap: .sm) {
Input(bind: q, label: "Search the guide").search
Highlight("Pages, components and stores hold state; a derived value reads it.", query: q)
Highlight("A state change repaints only what reads it.", query: q)
}
In a list of results
state q = "form"
for title in ["Forms and validation", "Formatting numbers", "Stores"] {
Text { Highlight(title, query: q) }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
text | String (positional) | — | The text, every match of |
query: | String | none: nothing marked | What to mark: every match, its case ignored, after trimming; empty marks nothing |
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.
No flags of its own.
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-highlight, stable across releases, so a stylesheet may target it.