Reference
EmptyState
What a list or a page shows when it has nothing yet: an icon, a title, a sentence and, in its block, what to do about it.
EmptyState(icon: String, title: String, text: String) { … }
Since 6.2.0
icon
title
text
Example
state count = 0
EmptyState(icon: "folder", title: "No projects yet", text: "A project holds your pages, components and stores.") {
Button("New project").primary { on click { count = count + 1 } }
Link("Read the guide", to: "/learn")
}
if count > 0 { Text("{count} project(s) asked for").muted }
A search with no results
state q = "zebra"
EmptyState(icon: "search", title: "No results for “{q}”", text: "Try a shorter word.") {
Button("Clear the search") { on click { q = "" } }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
icon: | String | none | An icon's name, drawn large and muted above the title, hidden from screen readers |
title: | String (required) | — | What is missing: |
text: | String | none | A sentence on what to do about it, muted, under the title |
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
children
Parts
The parts of EmptyState are written under its name, inside it. Each is described here, with what it takes.
EmptyState.Title
Its title.
EmptyState.Title(_ text: String)
| Prop | Type | Unset | Meaning |
|---|---|---|---|
text | String (positional) | none | The title |
EmptyState.Text
Its sentence.
EmptyState.Text(_ text: String)
| Prop | Type | Unset | Meaning |
|---|---|---|---|
text | String (positional) | none | The sentence |
EmptyState.Actions
What to do: the block it was given.
EmptyState.Actions { … }
Renders with the class wf-empty-state, stable across releases, so a stylesheet may target it.