Data display
Stat
A key figure with its label, an optional change and a trend that is read aloud, not shown by color alone.
JxStat
import 'package:jx_cli/ui.dart'
New in 0.0.3
Preview
- Revenue
- $48,200
- Increase: +12%
- vs last month
- Churn
- 2.1%
- Decrease: +0.4%
- vs last month
- Active users
- 1,204
- 0%
- no change
When to use it
- Dashboard tiles (revenue, sign-ups, errors).
- A summary row above a data table.
Minimal example
JxStat(label: 'Revenue', value: r'$48,200')
Complete example
A full Jaspr component you can paste into a project.
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';
/// A row of stats; a rising error rate is bad news, so it is a "down" trend.
class Overview extends StatelessComponent {
const Overview({super.key});
@override
Component build(BuildContext context) {
return const Component.element(
tag: 'section',
classes: 'grid cols:1 md:cols:3 gap:4',
children: [
JxStat(label: 'Sign-ups', value: '312', change: '+18%', trend: JxTrend.up, description: 'this week'),
JxStat(label: 'Error rate', value: '0.8%', change: '+0.3 pt', trend: JxTrend.down, description: 'this week'),
JxStat(
label: 'Uptime',
value: '99.98%',
change: '+0.01 pt',
trend: JxTrend.up,
trendLabels: {JxTrend.up: 'Better', JxTrend.down: 'Worse'},
),
],
);
}
}
Properties
| Property | Type | Default | Description |
|---|---|---|---|
label |
String |
required |
What the figure measures. |
value |
String |
required |
The figure, already formatted. |
change |
String? |
null |
The change, such as
+12%
.
|
trend |
JxTrend |
neutral |
up
is green,
down
red: pick by meaning, not by sign.
|
description |
String? |
null |
Context under the figure, such as "vs last month". |
trendLabels |
Map<JxTrend, String> |
Increase / Decrease |
Words read before the change. |
classes |
String? |
null |
Extra JX classes, appended after the component classes. |
Related types
| Name | Role |
|---|---|
JxTrend |
up, down, neutral. |
Customizing
-
Pass
classesto add or override utilities: they come last, soclasses: 'w:full'wins over the default width. - The tile uses the card surface; combine several in a grid.
Responsive
-
Takes the width of its column: one per row on phones in the example, three from
md.
Accessibility
-
A description list (
dl,dt,dd): the label is announced with its value. - The trend is said in words ("Increase: +12%"), the arrow is decorative: color is never the only signal.
Limitations
- No sparkline or chart.