Layout
Card
A surface that groups related content, with a title, a description and a footer for actions.
JxCard
import 'package:jx_cli/ui.dart'
Available since 0.0.1
Preview
Pro plan
For teams shipping every week.
Most popularNewsletter
When to use it
- A plan in a pricing grid.
- A settings group.
- A summary tile on a dashboard.
Minimal example
JxCard(title: 'Storage', [
p([.text('12 GB of 50 GB used.')]),
])
Complete example
A full Jaspr component you can paste into a project.
import 'package:jaspr/dom.dart';
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';
/// Pricing grid: one card per plan, the headings fit the page outline.
class Plans extends StatelessComponent {
const Plans({super.key});
@override
Component build(BuildContext context) {
return div(classes: 'grid cols:1 md:cols:3 gap:4', [
for (final (name, price) in [('Free', '0'), ('Pro', '12'), ('Team', '40')])
JxCard(
title: name,
titleLevel: 2,
description: '\$$price per month',
footer: [JxButton(fullWidth: true, [.text('Choose $name')])],
[
if (name == 'Pro') const JxBadge('Most popular', tone: JxTone.info),
],
),
]);
}
}
Properties
| Property | Type | Default | Description |
|---|---|---|---|
children |
List<Component> |
required |
Body of the card. |
title |
String? |
null |
Heading of the card. |
titleLevel |
int |
3 |
Heading level of the title, 2 to 6, to fit the page outline. |
description |
String? |
null |
Muted text under the title. |
footer |
List<Component>? |
null |
Shown under a separator, aligned to the end. Usually buttons. |
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. -
Remove the shadow with
classes: 'sh:none', or tighten it withp:4.
Responsive
-
The card fills its grid cell; lay cards out with
grid cols:1 md:cols:3 gap:4.
Accessibility
-
The title is a real heading (
h3by default), so cards show up in the page outline. -
Set
titleLevelso headings never skip a level.