Feedback
Badge
A short status label in five tones.
JxBadge
import 'package:jx_cli/ui.dart'
Available since 0.0.1
Preview
Neutral
Info
Success
Warning
Danger
When to use it
- Status in a table (Paid, Overdue).
- A "New" or "Beta" tag.
- A count next to a label.
Minimal example
JxBadge('Paid', tone: JxTone.success)
Complete example
A full Jaspr component you can paste into a project.
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';
class InvoiceStatus extends StatelessComponent {
const InvoiceStatus(this.status, {super.key});
final String status;
@override
Component build(BuildContext context) {
final tone = switch (status) {
'paid' => JxTone.success,
'overdue' => JxTone.danger,
'pending' => JxTone.warning,
_ => JxTone.neutral,
};
return JxBadge(status[0].toUpperCase() + status.substring(1), tone: tone);
}
}
Properties
| Property | Type | Default | Description |
|---|---|---|---|
label |
String |
required |
Text of the badge. |
tone |
JxTone |
neutral |
Color of the badge. |
classes |
String? |
null |
Extra JX classes, appended after the component classes. |
Customizing
-
Pass
classesto add or override utilities: they come last, soclasses: 'w:full'wins over the default width. -
Colors come from the theme families
blue,gray,red,greenandyellow. Redefine them intheme.extend.colorsto restyle every component at once.
Accessibility
-
Plain text in a
<span>: the label is read as is. Keep it meaningful without its color. - Tones use dark text on a light tint (contrast above 7:1).