Collapsible
A section whose title expands and collapses its content when clicked, or with Space or Enter while focused. It starts collapsed, and the framework keeps whether it is expanded.
ui.collapsibleBasic
ui.collapsible("Advanced options").default_open(true).children(|ui| { ui.text("The content is not built while collapsed.").text_sm().muted();});Closed until clicked
ui.collapsible("Details").children(|ui| { ui.text("Shown after a click on the title.").text_sm().muted();});API reference
| Setting | Description |
|---|---|
.default_open(open: bool) | Whether the section starts expanded the first time it appears. |
.children(f: impl FnOnce(&mut Ui<'a>) | Places the section; f declares its content while expanded. Returns the result of f, or None while collapsed. The height follows the theme's motion when the section opens or closes, and f still runs until the closing transition has finished. |