Navigation

Disclosure

A single collapsible section.

Rust
1use herogpui::components::disclosure::{Disclosure, DisclosureGroup};

Usage

Rust
1use herogpui::prelude::{Disclosure, DisclosureGroup};
2use gpui::prelude::*;
3
4Disclosure::new(
5    "disclosure-usage",
6    "Shipping details"
7)
8.child(gpui::div().child("Ships in 2-4 business days."))

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

DisclosureGroupDisclosure

Disclosure is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Disclosure uses.

Styling

Disclosure styling
StyleDescription
w_full()Full width matches; GPUI has no CSS layout/style containment toggle.
relative()The root establishes the indicator/content positioning context.
ButtonThe heading and trigger are represented by one built-in Button row.
Button::new(trigger_id).is_disabled(bool)Pointer, focus and disabled behavior come from Button, but the trigger is not independently styled or composed.
child(svg size(px(16.)))Size and trailing placement match; swaps chevron glyphs in one frame instead of rotating one glyph.
anim::entering + Motion::DISCLOSUREFades entry for 200ms but does not interpolate measured height and removes content immediately on collapse.
p(px(8.))Eight-pixel inset around panel content.

API reference

Builders

Disclosure builders
BuilderTypeDefaultDescription
expanded_keys(keys)Set<Key>The currently expanded items (controlled).
default_expanded_keys(keys)iterable of keysThe initially expanded items (uncontrolled).
on_expanded_change(callback)Fn(keys: Set<Key>) -> ()Reports the complete next expanded set.
allows_multiple_expanded(bool)boolfalseAllows more than one item to remain expanded.
is_disabled(bool)boolfalseDisables every disclosure trigger in the group.
item(key, title, content)key, title, contentComposed disclosure items; GPUI builds keyed items through a typed method.
is_expanded(bool)boolfalseControls whether the panel is expanded.
default_expanded(bool)boolfalseInitial expanded state when the disclosure owns its state; inherited from pinned.
content(render)AnyElement | render closureCompound heading, trigger and panel children; the GPUI control builds the trigger and accepts static body children through ParentElement or a state-aware body render closure.
new(id, title)id, titleCustom trigger content; accepts an id and title and builds a HeroGPUI Button.

Parts

Disclosure parts
PartDescription
DisclosureGroupFull-width owner of the expanded key set.
DisclosureRelative root for one trigger and panel.
DisclosureHeading wrapper is built into the monolithic trigger row.
DisclosureA built-in HeroGPUI Button rather than a separately composable trigger.
DisclosureBuilt-in 16px chevron whose glyph reflects expansion.
DisclosureMounted panel container while expanded.
DisclosureEight-pixel padded body around caller content.

States

Disclosure states
BuilderStateDescription
is_expanded(bool) / expanded_keysExpandedShows the body and uses the expanded indicator glyph.
is_disabled(bool)DisabledDisables one trigger or every trigger in the group.
Button tab_stop_handle + ring_if_focusedFocus visibleThe built-in Button owns keyboard focus and its focus ring.
allows_multiple_expanded(false)Single expansionOpening one item replaces the previous expanded set by default.
allows_multiple_expanded(true)Multiple expansionOpt-in mode toggles membership without closing siblings.