pub struct CollapsingHeader { /* private fields */ }
Expand description

A header which can be collapsed/expanded, revealing a contained Ui region.

egui::CollapsingHeader::new("Heading")
    .show(ui, |ui| {
        ui.label("Body");
    });

// Short version:
ui.collapsing("Heading", |ui| { ui.label("Body"); });

If you want to customize the header contents, see CollapsingState::show_header.

Implementations

The CollapsingHeader starts out collapsed unless you call default_open.

The label is used as an Id source. If the label is unique and static this is fine, but if it changes or there are several CollapsingHeader with the same title you need to provide a unique id source with Self::id_source.

By default, the CollapsingHeader is collapsed. Call .default_open(true) to change this.

Calling .open(Some(true)) will make the collapsing header open this frame (or stay open).

Calling .open(Some(false)) will make the collapsing header close this frame (or stay closed).

Calling .open(None) has no effect (default).

Explicitly set the source of the Id of this widget, instead of using title label. This is useful if the title label is dynamic or not unique.

If you set this to false, the CollapsingHeader will be grayed out and un-clickable.

This is a convenience for Ui::set_enabled.

👎Deprecated: Use the more powerful egui::collapsing_header::CollapsingState::show_header

Can the CollapsingHeader be selected by clicking it? Default: false.

👎Deprecated: Use the more powerful egui::collapsing_header::CollapsingState::show_header

If you set this to ‘true’, the CollapsingHeader will be shown as selected.

Example:

let mut selected = false;
let response = egui::CollapsingHeader::new("Select and open me")
    .selectable(true)
    .selected(selected)
    .show(ui, |ui| ui.label("Body"));
if response.header_response.clicked() {
    selected = true;
}

Should the CollapsingHeader show a background behind it? Default: false.

To show it behind all CollapsingHeader you can just use:

ui.visuals_mut().collapsing_header_frame = true;

Use the provided function to render a different CollapsingHeader icon. Defaults to a triangle that animates as the CollapsingHeader opens and closes.

For example:

fn circle_icon(ui: &mut egui::Ui, openness: f32, response: &egui::Response) {
    let stroke = ui.style().interact(&response).fg_stroke;
    let radius = egui::lerp(2.0..=3.0, openness);
    ui.painter().circle_filled(response.rect.center(), radius, stroke.color);
}

egui::CollapsingHeader::new("Circles")
  .icon(circle_icon)
  .show(ui, |ui| { ui.label("Hi!"); });

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.