Group¶

A transparent container that groups multiple views together without adding any visual structure or layout behavior. Group does not impose positioning or spacing on its children, unlike VStack, HStack, or other layout containers.
Common use cases include applying modifiers to multiple views at once, returning multiple views from conditional expressions, and organizing code without affecting visual output.
Constructor¶
nib.Group(
controls=None,
**modifiers,
)
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
controls |
list[View] |
None |
Child views to group together. The views are rendered without any additional layout structure imposed by the group itself. |
**modifiers |
Common view modifiers applied to the group as a whole, affecting all children: padding, background, foreground_color, opacity, font, etc. |
Examples¶
Shared styling¶
Apply a single modifier to multiple views at once by wrapping them in a Group.

import nib
def main(app: nib.App):
app.title = "Diagnostics"
app.icon = nib.SFSymbol("stethoscope")
app.build(
nib.VStack(
controls=[
nib.Text("Diagnostics", font=nib.Font.HEADLINE),
nib.Group(
controls=[
nib.Label("Disk almost full", icon="exclamationmark.triangle"),
nib.Label("Backup overdue", icon="clock.badge.exclamationmark"),
],
foreground_color=nib.Color.ORANGE,
),
nib.Group(
controls=[
nib.Label("Firewall on", icon="checkmark.shield"),
nib.Label("Updates current", icon="checkmark.circle"),
],
foreground_color=nib.Color.GREEN,
),
],
spacing=8,
padding=16,
alignment=nib.Alignment.LEADING,
)
)
nib.run(main)
Conditional content¶
Use Group to return multiple views from a conditional branch where a single parent is required.

import nib
def main(app: nib.App):
app.title = "Build"
app.icon = nib.SFSymbol("hammer")
build_failed = True
if build_failed:
details = nib.Group(
controls=[
nib.Text(
"Build failed",
font=nib.Font.HEADLINE,
foreground_color=nib.Color.RED,
),
nib.Text(
"tests/test_api.py::test_login",
style=nib.TextStyle(monospaced=True),
),
nib.Text(
"AssertionError: expected 200, got 401",
foreground_color=nib.Color.SECONDARY,
),
],
)
else:
details = nib.Text(
"Build passed", font=nib.Font.HEADLINE, foreground_color=nib.Color.GREEN
)
app.build(
nib.VStack(
controls=[details, nib.Button("Retry", action=lambda: None)],
spacing=8,
padding=16,
alignment=nib.Alignment.LEADING,
)
)
nib.run(main)
Related¶
- VStack
- Section
- Modifiers Reference: modifier arguments