-
Notifications
You must be signed in to change notification settings - Fork 0
LayrzChip
A static, visual-only compact label widget with optional leading icon and delete affordance.
Metadata
Mirrors: ThemedChip (layrz_theme)
Phase: M2 (Core primitives)
Domain: Data
Primitive: Hand-rolled (Container + GestureDetector)
Status: Confirmed scope.
LayrzChip is a compact label with no selection state, no toggle behavior, and no selection modes. It is visual-only — a static representation of a piece of data (tag, label, badge, status indicator). The only interactive element is an optional delete affordance.
Chips are commonly used for:
- Tag lists and categories
- Filter badges
- Status indicators
- Compact labels in lists and chips groups
Key principle: Chips do not implement selection control. Selection (single or multi) belongs to input components like LayrzSelectInput or LayrzMultiSelectInput, not to chip widgets. If you need the user to choose items, use an input component, not chips.
- Static, not interactive: The chip itself is not tappable. Only the optional delete icon responds to taps.
- Visual representation: Chips express semantic meaning (info, success, danger, etc.) via color and style.
- Fixed sizing: Height and spacing are standardized. Chips are compact by design.
- Flexible styling: Three style variants (filled, outlined, filledTonal) with six semantic types (info, success, warning, danger, context, custom).
-
Grouped displays: Use
LayrzChipGroupto manage multiple chips with optional overflow handling.
const LayrzChip({
required String labelText,
IconData? leadingIcon,
VoidCallback? onDelete,
LayrzChipStyle style = LayrzChipStyle.filledTonal,
LayrzChipType type = LayrzChipType.custom,
Color? color,
Key? key,
})-
labelText(String, required) — The text label displayed in the chip. -
leadingIcon(IconData?, default null) — Optional icon displayed before the label (from flutter_material_design_icons). -
onDelete(VoidCallback?, default null) — Callback invoked when the delete icon is tapped. When null, no delete icon is rendered. -
style(LayrzChipStyle, defaultfilledTonal) — Visual style of the chip. -
type(LayrzChipType, defaultcustom) — Semantic type determining the accent color. Whentype == custom, thecolorparameter is honored. -
color(Color?, default null) — Explicit accent color override. Only used whentype == custom. Assertion enforces thatcoloris null whentypeis not custom.
double computeWidth(BuildContext context)Returns the intrinsic width of the chip in logical pixels, including padding, icon space, and label width. Used by LayrzChipGroup in compact mode to determine when to show the +N overflow indicator.
Three visual style variants:
enum LayrzChipStyle {
/// Solid fill with accent color, no border.
filled,
/// Outlined only, no fill; accent-colored border.
outlined,
/// Subtle tonal fill (semi-transparent) with no border.
filledTonal,
}-
filled— Solid accent background, no border. Best for emphasized labels. -
outlined— Transparent background with accent border. Best for secondary labels. -
filledTonal— Subtle tonal (semi-transparent) background, no border. Default and recommended for most use cases; best for neutral or neutral-secondary labels.
Six semantic type values controlling the accent color:
enum LayrzChipType {
/// Informational color — LayrzTokens.colors.info (blue).
info,
/// Success color — LayrzTokens.colors.success (green).
success,
/// Warning color — LayrzTokens.colors.warning (orange).
warning,
/// Danger color — LayrzTokens.colors.danger (red).
danger,
/// Contextual color — LayrzTokens.colors.contextual.
context,
/// Custom color — use explicit color parameter.
custom,
}When type is one of the semantic types (info, success, warning, danger, context), the corresponding token color is applied. When type == custom, the color parameter is honored (defaulting to primary if both type is custom and color is null).
LayrzChip has no selection state, hover highlight, or focus state. The chip is static. Only the optional delete affordance (if onDelete is non-null) is interactive:
-
Delete icon: Appears to the right of the label when
onDeleteis non-null. Responds to hover, press, and focus. Tapping invokes the callback. - Chip itself: Not tappable. Click and hover do nothing.
LayrzChip(
labelText: 'Flutter',
)LayrzChip(
labelText: 'Success',
leadingIcon: MdiIcons.checkboxOutline,
type: LayrzChipType.success,
)LayrzChip(
labelText: 'Remove me',
onDelete: () => setState(() => labels.remove('Remove me')),
type: LayrzChipType.warning,
style: LayrzChipStyle.outlined,
)LayrzChip(
labelText: 'Custom Color',
type: LayrzChipType.custom,
color: Color(0xFF9C27B0), // Purple
style: LayrzChipStyle.filled,
)- No selection semantics: Chips do not track whether they are "selected" or "active". If you need selection control, use an input component instead.
-
Delete affordance is optional: Omit
onDeleteto create a read-only label. Pass a callback to make the chip dismissible. -
Pill radius: Border radius is always
tokens.radius.full, giving chips their characteristic rounded-rectangle shape. - No size parameters: Chip size and spacing are fixed and not configurable. Constraints from the parent layout apply, but the intrinsic sizing is standardized.
- LayrzChipGroup — Container for multiple chips with overflow handling
Made with ❤️ by Golden M, Inc.
- LayrzTextInput
- LayrzSelectableAction
- LayrzSelectionToolbar
- LayrzTextSelectionControls
- LayrzSelectionMagnifier
- LayrzSelectionHandlePainter
- LayrzTextAreaInput
- LayrzComboBoxInput
- LayrzNumberInput
- LayrzPasswordInput
- LayrzCheckboxInput
- LayrzRadioInput
- LayrzSelectInput
- LayrzMultiSelectInput
- LayrzSearchInput
- LayrzDualListInput
- LayrzDurationInput