Reference
Accordion
Sections a reader opens one by one, each a native <details>: Accordion.Item("Shipping") { … }. .single keeps one open at a time.
Accordion(single: Bool) { … }
Since 6.2.0
single
How long does shipping take?
Two to four working days in the EU, a week elsewhere.
Can I return an order?
Within thirty days, unused and in its box.
Start a returnDo you ship abroad?
To 40 countries; the checkout lists them.
Example
Accordion.single {
Accordion.Item("How long does shipping take?") {
Text("Two to four working days in the EU, a week elsewhere.")
}
Accordion.Item("Can I return an order?", open: true) {
Text("Within thirty days, unused and in its box.")
Link("Start a return", to: "/learn")
}
Accordion.Item("Do you ship abroad?") {
Text("To 40 countries; the checkout lists them.")
}
}
Several open at once
Accordion {
Accordion.Item("Account", open: true) { Text("Your name and email.") }
Accordion.Item("Billing", open: true) { Text("Your plan and invoices.") }
}
A title of your own
Accordion {
Accordion.Item("Errors") {
Accordion.Summary { Text("Errors ") Badge("3").danger.pill }
Accordion.Panel { Text("Three pages failed to build.") }
}
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
single: | Bool | false: each opens on its own | One open at a time: opening one closes the others (every item given one |
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.
.single
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Parts
The parts of Accordion are written under its name, inside it. Each is described here, with what it takes.
Accordion.Item
One section: its title is what a reader presses, its block what opens.
Accordion.Item(_ title: String, open: Bool, name: String) { … }
| Prop | Type | Unset | Meaning |
|---|---|---|---|
title | String (positional) | — | What a reader presses: the |
open: | Bool | false | Open when it is drawn; the reader opens and closes it after. Written as a flag, |
name: | String | none | Items of one name open one at a time, as |
.open
Drawn for it
What Accordion draws itself, by the class a stylesheet can select. They are not written.
| Part | Class | Meaning |
|---|---|---|
Accordion.Summary | — | What a reader presses to open an item: its title. |
Accordion.Panel | — | What opens: the item's block. |
Renders with the class wf-accordion, stable across releases, so a stylesheet may target it.
Codes this can raise
These controls list the props' cases; the example below shows them written.