Skip to content

Drawer

A drawer: a panel that slides up from the bottom of the window, as tall as its content, over a dimmed window. For a short task on a small screen, or one that keeps the page in view above it.

ui.drawer
if ui.button("Open drawer").outline().clicked() {
ui.open_dialog("goal");
}
let drawer = ui.drawer("goal").title("Move goal");
drawer.description("Set your daily activity goal.").children(|ui| {
ui.number_input(&mut self.goal, 0..=1000).step(10).w_fill();
if ui.button("Submit").primary().w_fill().clicked() {
ui.close_dialog("goal");
}
if ui.button("Cancel").outline().w_fill().clicked() {
ui.close_dialog("goal");
}
});

API reference

SettingDescription
.title(title: impl Display)The title, which also names the drawer for screen readers.
.description(text: impl Display)A line under the title, in muted text.
.w(width: impl crate::style::Length)The width of the content, 480 by default; the drawer itself is as wide as the window, and the content is in the middle of it. A window narrower than this is filled.
.children(f: impl FnOnce(&mut Ui<'a>)Declares the content with f while open: a column under the title.