-
Notifications
You must be signed in to change notification settings - Fork 0
LayrzChipGroup
A responsive container for multiple LayrzChip widgets with configurable overflow behavior.
Metadata
Mirrors: ThemedChipGroup (layrz_theme)
Phase: M2 (Core primitives)
Domain: Data
Primitive: SingleChildScrollView + Row
Status: Confirmed scope.
LayrzChipGroup manages the horizontal layout of multiple chips with two layout modes:
-
.none(default): Chips render on a single horizontal row that scrolls when they overflow available width. No clipping, no overflow indicator. -
.compact: Chips are clamped to available width. When chips overflow, the remainder is collapsed into a single+Nchip whose tooltip lists the hidden labels.
Use LayrzChipGroup to display lists of tags, filter badges, or dynamic label collections without manual overflow handling.
-
Low friction for simple cases: Default
.nonemode requires no width constraint; it scrolls naturally. -
Constrained layouts: Use
.compactmode when you need chips to fit within a fixed width (e.g., in a card, sidebar, or responsive container). -
Overflow indicator: The
+Nchip is context-colored (not configurable) and shows a tooltip listing the hidden chip labels when hovered or long-pressed. - Measurement caveat (compact mode): The widget measures each chip individually to determine overflow, which costs one text layout per chip per build. Use sparingly in hot lists.
const LayrzChipGroup({
required List<LayrzChip> chips,
LayrzChipGroupBehavior behavior = LayrzChipGroupBehavior.none,
double? spacing,
Alignment alignment = Alignment.centerLeft,
Key? key,
})-
chips(List, required) — The list of chips to display. -
behavior(LayrzChipGroupBehavior, default.none) — Layout behavior for overflow handling. -
spacing(double?, default null) — Space between each chip in logical pixels. When null, defaults totokens.spacing.sp2(8 logical pixels). Pass 0 for no spacing; pass any other value to override. -
alignment(Alignment, defaultAlignment.centerLeft) — Horizontal and vertical alignment of the chips. Only honored by.nonebehavior;.compactignores this parameter.
Two layout modes:
enum LayrzChipGroupBehavior {
/// Chips render on a single horizontal row that scrolls on overflow.
///
/// This is the default behavior. Provides unlimited horizontal scrolling
/// space without requiring a finite max-width constraint.
none,
/// Chips are clamped to available width; remainder collapses into +N.
///
/// This behavior requires a finite max-width constraint (asserts otherwise).
/// When overflow occurs, visible chips are shown, and any remaining chips
/// are collapsed into a single +N chip whose tooltip lists the hidden labels.
/// The N is clamped to 1–9.
compact,
}- Default behavior.
- Chips render on a single horizontal row.
- Scrolls naturally when overflow occurs (no clipping, no indicator).
- No width constraint required.
-
alignmentparameter is honored; chips can be aligned to start, center, end, or top/bottom.
- Chips are measured and laid out within the available width.
- When overflow would occur, visible chips are shown, and the remainder is collapsed into a
+Nchip. -
Requires a finite
maxWidthconstraint; asserts if not provided (e.g., in an unboundedColumn). -
alignmentparameter is ignored; chips are always left-aligned. -
Tooltip on
+Nchip: Hovering or long-pressing the+Nchip shows a tooltip listing all hidden chip labels, one per line.
Measurement caveat: In compact mode, the widget calls computeWidth() on each chip to measure its rendered size, then determines whether it fits within the available width. This costs one full text layout per chip per build. Avoid using .compact with very large chip lists in hot rebuild scenarios.
LayrzChipGroup(
chips: [
LayrzChip(labelText: 'Flutter'),
LayrzChip(labelText: 'Dart'),
LayrzChip(labelText: 'Material Design'),
],
)The chips render on a scrollable row. When the group is wider than the available space, users can scroll horizontally.
SizedBox(
width: 300, // Constrained width
child: LayrzChipGroup(
chips: [
LayrzChip(labelText: 'Tag 1'),
LayrzChip(labelText: 'Tag 2'),
LayrzChip(labelText: 'Tag 3'),
LayrzChip(labelText: 'Tag 4'),
LayrzChip(labelText: 'Tag 5'),
],
behavior: LayrzChipGroupBehavior.compact,
),
)If all five chips do not fit within 300 logical pixels, the visible chips are shown, and the remainder appears as +2 with a tooltip listing the hidden labels.
LayrzChipGroup(
chips: [...],
spacing: 12, // Override default tokens.spacing.sp2
behavior: LayrzChipGroupBehavior.none,
)LayrzChipGroup(
chips: [...],
alignment: Alignment.center, // Center chips horizontally
behavior: LayrzChipGroupBehavior.none,
)- Chips are always static: Even in a group, chips themselves are not selectable or interactive (except for the delete affordance on individual chips).
-
Overflow indicator: In
.compactmode, the+Nchip is rendered as a context-colored chip with the label+N(where N is between 1 and 9). Tapping the+Nchip does nothing; it is purely informational. Hover or long-press to see the tooltip. - No reordering or rearrangement: Chips are displayed in the order they are provided. The group does not support dragging or reordering.
-
.compactperformance: Measuring each chip individually costs one layout per chip. For very large lists (100+ chips), prefer the.nonemode with scrolling, or paginate the chips.
- LayrzChip — Individual chip widget
Made with ❤️ by Golden M, Inc.
- LayrzTextInput
- LayrzSelectableAction
- LayrzSelectionToolbar
- LayrzTextSelectionControls
- LayrzSelectionMagnifier
- LayrzSelectionHandlePainter
- LayrzTextAreaInput
- LayrzComboBoxInput
- LayrzNumberInput
- LayrzPasswordInput
- LayrzCheckboxInput
- LayrzRadioInput
- LayrzSelectInput
- LayrzMultiSelectInput
- LayrzSearchInput
- LayrzDualListInput
- LayrzDurationInput