Accordion
Stacked disclosures: one panel at a time, animated on the shared clock.
Titles that expand one panel of content at a time (Multiple for
independent panels). The reveal grows on the shared clock — content is measured at natural
height and clipped, never reflowed mid-flight.
Installation
Use the module import (the default), or own the source: lotusui add
vendors the component into your app and lotusui update keeps the copy mergeable —
see Registry.
go get github.com/ikaito-com/lotusui
# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add accordion
Usage
var acc lotusui.Accordion // zero value: all closed, single-open
acc.Layout(th, gtx,
lotusui.AccordionItem{Title: "Is it accessible?", Content: answer1},
lotusui.AccordionItem{Title: "Is it styled?", Content: answer2},
)
Multiple
Multiple lets panels expand independently.
acc := lotusui.Accordion{Multiple: true}
Disabled item
lotusui.AccordionItem{Title: "Premium feature information", Disabled: true, Content: c}
Borders
Bordered wraps the accordion in a rounded outline with side padding.
acc := lotusui.Accordion{Bordered: true}
Card
Inside a padded surface — composition with SurfaceCard.
lotusui.SurfaceCard(th, gtx, acc.Layout(…))
API
| Option | Type | Description |
|---|---|---|
Open | int | The expanded item in single mode; -1 = all closed. |
Multiple | bool | Independent panels, tracked in Expanded. |
Expanded | []bool | Per-item state in Multiple mode. |