Skip to main content

Badge

A small pill-shaped label conveying status, category, or count.

When to use it

Use a Badge to annotate an item with a short status or category label — for example "Active", "Beta", or an unread count. Combine with showDot to add a small coloured indicator before the label.

Import

import 'package:catalyst_ui/catalyst_ui.dart';

Usage

Badge(
variant: BadgeVariant.success,
child: const Text('Active'),
)

Parameters

ParameterTypeDefaultDescription
childWidgetrequiredThe label content, typically a Text widget.
variantBadgeVariantBadgeVariant.neutralThe visual variant.
showDotboolfalseShows a small coloured dot before child when true.
sizeBadgeSizeBadgeSize.mediumThe size.
elevatedboolfalseAdds a small shadow to this badge when true.

Sizes

BadgeSize values: small (20px), medium (24px, default), large (28px).

Variants

Built-in BadgeVariant presets:

  • BadgeVariant.neutral — grey; non-semantic label.
  • BadgeVariant.info — blue tint; informational label.
  • BadgeVariant.success — green tint; positive or success label.
  • BadgeVariant.warning — amber tint; cautionary label.
  • BadgeVariant.danger — red tint; error or destructive label.
  • BadgeVariant.brand — brand-coloured fill; primary emphasis label.

Define your own by subclassing BadgeVariant and implementing resolve:

class PremiumBadgeVariant extends BadgeVariant {
const PremiumBadgeVariant();


BadgeVariantStyle resolve(ColorScheme cs) => BadgeVariantStyle(
backgroundColor: const Color(0xFFFFF7E6),
foregroundColor: const Color(0xFFB45309),
dotColor: const Color(0xFFD97706),
);
}

See Variants & Tones for the full pattern.