Status bar
A one-line bar along the bottom of a window, with left, centre and right slots in muted 12-point text.
Editor
StatusBar::new().label("Editor status").show(ui, |bar| {
bar.left(|ui| {
if ui.add(Button::ghost("main").xsmall()).clicked() {
state.clicks.push("Switch branch");
}
ui.add(Separator::vertical().length(12.0));
let hues = tokens(ui.ctx()).hues;
ui.add(
glyph(ui.ctx(), "check")
.tint(hues.green)
.fit_to_exact_size(egui::vec2(12.0, 12.0)),
);
ui.label("0");
ui.add(
glyph(ui.ctx(), "bell")
.tint(hues.blue)
.fit_to_exact_size(egui::vec2(12.0, 12.0)),
);
ui.label("2");
});
bar.right(|ui| {
if ui.add(Button::ghost("Ln 12, Col 34").xsmall()).clicked() {
state.clicks.push("Go to line");
}
ui.add(Separator::vertical().length(12.0));
ui.add(Button::ghost("UTF-8").xsmall());
ui.add(Button::ghost("Rust").xsmall());
});
});
Application
StatusBar::new().show(ui, |bar| {
bar.left(|ui| {
ui.label("Connected");
});
bar.center(|ui| {
ui.add(
Progress::new()
.value(45.0)
.style(&progress_styles::Circular)
.width(12.0),
);
ui.label("Syncing…");
});
bar.right(|ui| {
ui.label("All changes saved");
ui.add(Button::ghost("3").xsmall());
});
});
Inline action
// TonePush's state line: parts a dot apart, and an action link.
StatusBar::new().show(ui, |bar| {
bar.left(|ui| {
ui.label("Pedal connected");
ui.label("·");
if state.skipped {
ui.label("Backup skipped");
} else {
ui.label("Backing up the pedal");
let skip = Button::new("Skip")
.style(&fastframe_ui::button_styles::Link)
.xsmall();
if ui.add(skip).clicked() {
state.skipped = true;
}
}
});
});
Alignment
StatusBar::new().id_salt(1).show(ui, |bar| {
bar.center(|ui| ui.label("Centre only: at the start"));
});
StatusBar::new().id_salt(2).show(ui, |bar| {
bar.left(|ui| ui.label("Left"));
bar.center(|ui| ui.label("Centre: against the left slot's end"));
});
StatusBar::new().id_salt(3).show(ui, |bar| {
bar.center(|ui| ui.label("Centre: at the start"));
bar.right(|ui| ui.label("Right"));
});
StatusBar::new().id_salt(4).show(ui, |bar| {
bar.left(|ui| ui.label("Left"));
bar.center(|ui| ui.label("Centred between both"));
bar.right(|ui| ui.label("Right"));
});
The story above is gallery/src/stories/status_bar.rs, running in your browser. Every snippet on this page is cut from it.