Reference
Sheet
A modal <dialog> that comes in from an edge: the bottom (a phone's filters, a share list) or the start or end of the line. Dragged by its handle or heading toward its edge it closes; a bottom sheet with snap: points settles at the nearest.
Sheet(visible: State, title: String, closable: Bool, …) { … }
Since 6.2.0
title
side
bottom
start
end
dismiss
any
escape
none
Sorted by new
Example
state filters = false
state sort = "new"
state inStock = true
Button("Filters") { on click { filters = true } }
Sheet(visible: filters, title: "Filters", snap: [0.5, 1]).closable {
Radio(bind: sort, value: "new", label: "Newest first")
Radio(bind: sort, value: "price", label: "Lowest price")
Switch(bind: inStock, label: "In stock only")
Sheet.Footer { Button("Show results").primary.full { on click { filters = false } } }
}
Text("Sorted by {sort}").muted
From the end of the page
state details = false
Button("Details") { on click { details = true } }
Sheet(visible: details, side: .end, title: "Deploy #418").closable {
Text("Opened 3 days ago by Ada")
}
From the start, named by a label
state nav = false
Button("Menu") { on click { nav = true } }
Sheet(visible: nav, side: .start, label: "Navigation") {
Link("Learn", to: "/learn")
Link("Reference", to: "/reference")
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
visible: | State | none: it never opens | Whether it is open: a |
title: | String | none | The heading at the top, and the accessible name; a value that reads state follows it; a |
closable: | Bool | false | A close button (×) in the heading row, which closes it as Escape does; with no |
side: | one of its cases | bottom | The edge it slides in from, and is dragged back toward to close. Written as a flag,
|
snap: | [Number] | none: as tall as its content, up to 90% of the window | A bottom sheet's heights, as fractions of the window's ( |
label: | String | none | Its accessible name when it has no |
dismiss: | one of its cases | any | What closes it besides the page's own button and
|
initialFocus: | Element | none | What takes the focus when it opens, by its |
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.
.closable
.bottom
.start
.end
.any
.escape
.none
Events
| Event | Sends | Meaning |
|---|---|---|
on close | — |
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Parts
The parts of Sheet are written under its name, inside it. Each is described here, with what it takes.
Sheet.Title
What the sheet's heading draws, in place of its title:'s words, which stay its name.
Sheet.Title { … }
Sheet.Footer
The sheet's action row, kept in view below what scrolls.
Sheet.Footer { … }
Renders with the class wf-sheet, stable across releases, so a stylesheet may target it.