DisclosureGroup¶

A collapsible container that shows or hides content on demand. DisclosureGroup displays a label with a disclosure indicator (chevron) that users can tap to reveal or hide the contained content.
This is useful for organizing optional or advanced settings, creating accordion-style interfaces, or reducing visual clutter by hiding less frequently used options.
Constructor¶
nib.DisclosureGroup(
label=None,
controls=None,
is_expanded=False,
on_expand=None,
**modifiers,
)
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
label |
str |
required | The text label displayed in the header. This text is always visible regardless of the expansion state. |
controls |
list[View] |
None |
Child views shown when the group is expanded and hidden when collapsed. |
is_expanded |
bool |
False |
Initial expansion state. True starts expanded with content visible; False starts collapsed. |
on_expand |
Callable[[bool], None] |
None |
Callback invoked when the expansion state changes. Receives True when expanded, False when collapsed. |
**modifiers |
Common view modifiers: padding, background, foreground_color, opacity, width, height, etc. |
Examples¶
Advanced options¶

import nib
def main(app: nib.App):
app.title = "Export"
app.icon = nib.SFSymbol("square.and.arrow.up.on.square")
app.height = 260
app.build(
nib.VStack(
controls=[
nib.Picker("Format", selection="PNG", options=["PNG", "JPEG", "PDF"]),
nib.Toggle("Open after export", is_on=True),
nib.DisclosureGroup(
"Advanced",
controls=[
nib.Toggle("Include metadata", is_on=False),
nib.Toggle("Embed colour profile", is_on=True),
nib.Slider(
label="Quality", value=80, min_value=0, max_value=100
),
],
),
nib.Button(
"Export",
action=lambda: None,
style=nib.ButtonStyle.BORDERED_PROMINENT,
),
],
spacing=12,
padding=16,
width=280,
alignment=nib.Alignment.LEADING,
)
)
nib.run(main)
Initially expanded group¶

import nib
def main(app: nib.App):
app.title = "Network"
app.icon = nib.SFSymbol("network")
app.height = 200
def row(label, value):
return nib.HStack(
controls=[
nib.Text(label, foreground_color=nib.Color.SECONDARY),
nib.Spacer(),
nib.Text(value, style=nib.TextStyle(monospaced=True)),
]
)
app.build(
nib.VStack(
controls=[
nib.DisclosureGroup(
"Wi-Fi",
controls=[
nib.Toggle("Wi-Fi", is_on=True),
nib.Toggle("Ask to join networks", is_on=False),
],
is_expanded=True,
),
nib.DisclosureGroup(
"Details",
controls=[
row("IP address", "192.168.1.24"),
row("Router", "192.168.1.1"),
row("DNS", "1.1.1.1"),
],
is_expanded=False,
),
],
spacing=12,
padding=16,
width=280,
alignment=nib.Alignment.LEADING,
)
)
nib.run(main)