Disclosure
A single collapsible section.
1use herogpui::components::disclosure::{Disclosure, DisclosureGroup};Usage
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
| Style | Description |
|---|---|
w_full() | Full width matches; GPUI has no CSS layout/style containment toggle. |
relative() | The root establishes the indicator/content positioning context. |
Button | The 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::DISCLOSURE | Fades 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
| Builder | Type | Default | Description |
|---|---|---|---|
expanded_keys( | Set< | — | The currently expanded items (controlled). |
default_expanded_keys( | iterable of keys | — | The initially expanded items (uncontrolled). |
on_expanded_change( | Fn( | — | Reports the complete next expanded set. |
allows_multiple_expanded( | bool | false | Allows more than one item to remain expanded. |
is_disabled( | bool | false | Disables every disclosure trigger in the group. |
item( | key, | — | Composed disclosure items; GPUI builds keyed items through a typed method. |
is_expanded( | bool | false | Controls whether the panel is expanded. |
default_expanded( | bool | false | Initial expanded state when the disclosure owns its state; inherited from pinned. |
content( | AnyElement | | — | Compound 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, | — | Custom trigger content; accepts an id and title and builds a HeroGPUI Button. |
Parts
| Part | Description |
|---|---|
DisclosureGroup | Full-width owner of the expanded key set. |
Disclosure | Relative root for one trigger and panel. |
Disclosure | Heading wrapper is built into the monolithic trigger row. |
Disclosure | A built-in HeroGPUI Button rather than a separately composable trigger. |
Disclosure | Built-in 16px chevron whose glyph reflects expansion. |
Disclosure | Mounted panel container while expanded. |
Disclosure | Eight-pixel padded body around caller content. |
States
| Builder | State | Description |
|---|---|---|
is_expanded(bool) / expanded_keys | Expanded | Shows the body and uses the expanded indicator glyph. |
is_disabled(bool) | Disabled | Disables one trigger or every trigger in the group. |
Button tab_stop_handle + ring_if_focused | Focus visible | The built-in Button owns keyboard focus and its focus ring. |
allows_multiple_expanded(false) | Single expansion | Opening one item replaces the previous expanded set by default. |
allows_multiple_expanded(true) | Multiple expansion | Opt-in mode toggles membership without closing siblings. |