Card
LayoutA surface that groups related content: <Card.Root> holds an optional Card.Figure (an image that runs to the edges; inset pads it), a Card.Header (a Card.Title heading, at level 3 by default; a Card.Description; a Card.Action in the end corner), a Card.Content and a Card.Footer. variant: default (border and shadow), outline, dash (an empty or drop area), soft (a fill, no border). size: sm, default, lg (padding, gaps and title). layout: the figure above or below the text (vertical), beside it (horizontal, or responsive from the md breakpoint), or behind it with a scrim (overlay); beside or behind, the text goes in a Card.Body.
import { Card } from '@limerdev/zest'; Separator. A clickable card: put a link or button inside it instead of making the card the target.Examples
Image
A figure that runs to the card's edges, a header with a badge, and actions.
<script lang="ts">
import { Badge, Button, Card } from '@limerdev/zest';
</script>
<Card.Root class="w-80">
<Card.Figure class="h-40"><img src="/examples/hills.svg" alt="Hills at sunset" /></Card.Figure>
<Card.Header>
<Card.Title>Autumn retreat</Card.Title>
<Card.Description>14–16 October, Åre</Card.Description>
<Card.Action><Badge variant="success">Booked</Badge></Card.Action>
</Card.Header>
<Card.Content class="text-sm">
Three days, 24 people. The invoice goes out on 1 October.
</Card.Content>
<Card.Footer class="justify-end">
<Button size="sm" variant="ghost">Details</Button>
<Button size="sm">Send invoice</Button>
</Card.Footer>
</Card.Root> Header and actions
No figure: a header with a title, description and an action; content; a footer.
<script lang="ts">
import { Button, Card } from '@limerdev/zest';
</script>
<Card.Root class="w-80">
<Card.Header>
<Card.Title>Acme AB</Card.Title>
<Card.Description>Customer since 2021</Card.Description>
<Card.Action><Button size="sm" variant="outline">Edit</Button></Card.Action>
</Card.Header>
<Card.Content class="text-sm">12 open invoices, 48 200 kr due.</Card.Content>
<Card.Footer><Button size="sm">View invoices</Button></Card.Footer>
</Card.Root> Variants
variant: a border and shadow (default), a border only, a dashed border, a soft fill.
<script lang="ts">
import { Card, type CardVariant } from '@limerdev/zest';
const variants: CardVariant[] = ['default', 'outline', 'dash', 'soft'];
</script>
<div class="grid w-full gap-4 sm:grid-cols-2">
{#each variants as variant (variant)}
<Card.Root {variant}>
<Card.Header>
<Card.Title class="capitalize">{variant}</Card.Title>
<Card.Description>variant="{variant}"</Card.Description>
</Card.Header>
</Card.Root>
{/each}
</div> Sizes
size: the padding, the gaps and the title.
<script lang="ts">
import { Card, type CardSize } from '@limerdev/zest';
const sizes: CardSize[] = ['sm', 'default', 'lg'];
</script>
<div class="flex flex-wrap items-start gap-4">
{#each sizes as size (size)}
<Card.Root {size} class="w-60">
<Card.Header>
<Card.Title>Size {size}</Card.Title>
<Card.Description>size="{size}"</Card.Description>
</Card.Header>
<Card.Content class="text-sm">Padding and gaps follow the size.</Card.Content>
</Card.Root>
{/each}
</div> Side
layout="horizontal" puts the figure beside a Card.Body; "responsive" does so from md.
<script lang="ts">
import { Button, Card } from '@limerdev/zest';
</script>
<div class="grid w-full max-w-2xl gap-4">
<Card.Root layout="horizontal">
<Card.Figure><img src="/examples/lake.svg" alt="A lake below mountains" /></Card.Figure>
<Card.Body>
<Card.Header>
<Card.Title>Lakeside office</Card.Title>
<Card.Description>Room for 12, from 1 March</Card.Description>
</Card.Header>
<Card.Content class="text-sm">Desks, two meeting rooms and a kitchen.</Card.Content>
<Card.Footer class="justify-end"><Button size="sm">Book a visit</Button></Card.Footer>
</Card.Body>
</Card.Root>
<Card.Root layout="responsive" variant="outline">
<Card.Figure inset><img src="/examples/fields.svg" alt="Green fields" /></Card.Figure>
<Card.Body>
<Card.Header>
<Card.Title>Inset figure</Card.Title>
<Card.Description>Padded, with rounded corners; beside the text from md.</Card.Description>
</Card.Header>
</Card.Body>
</Card.Root>
</div> Overlay
layout="overlay": the figure is the background, with a scrim behind the text.
<script lang="ts">
import { Button, Card } from '@limerdev/zest';
</script>
<Card.Root layout="overlay" class="w-80">
<Card.Figure><img src="/examples/lake.svg" alt="" /></Card.Figure>
<Card.Body>
<Card.Header>
<Card.Title>Spring kick-off</Card.Title>
<Card.Description>The whole company, 3 April</Card.Description>
</Card.Header>
<Card.Footer><Button size="sm">Sign up</Button></Card.Footer>
</Card.Body>
</Card.Root> Figures
Summary figures in a grid of small cards: only a header and content.
<script lang="ts">
import { Badge, Card } from '@limerdev/zest';
type Figure = { label: string; value: string; change: string; up: boolean };
const figures: Figure[] = [
{ label: 'Invoiced', value: '312 400 kr', change: '+12%', up: true },
{ label: 'Paid', value: '264 900 kr', change: '+8%', up: true },
{ label: 'Overdue', value: '18 300 kr', change: '−4%', up: false }
];
</script>
<div class="grid w-full gap-4 sm:grid-cols-3">
{#each figures as figure (figure.label)}
<Card.Root size="sm">
<Card.Header>
<Card.Description>{figure.label}</Card.Description>
<Card.Action>
<Badge variant={figure.up ? 'success' : 'outline'}>{figure.change}</Badge>
</Card.Action>
</Card.Header>
<Card.Content class="text-2xl font-semibold tabular-nums">{figure.value}</Card.Content>
</Card.Root>
{/each}
</div> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Card.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| layout | "horizontal" | "vertical" | "responsive" | "overlay" | 'vertical' | Where a Card.Figure goes: above or below the text (vertical), beside it (horizontal), beside it from the md breakpoint (responsive), or behind it as the background (overlay). Beside or behind, put the text in a Card.Body. |
| size | "default" | "sm" | "lg" | 'default' | The padding, the gaps and the title's size. |
| variant | "outline" | "default" | "dash" | "soft" | 'default' | The look: a border and a shadow (default), a border only (outline), a dashed border (dash, for an empty or drop area), or a soft fill without a border (soft). |
Card.Figure
| Prop | Type | Default | Description |
|---|---|---|---|
| inset | boolean | false | Pad the figure and round the image, instead of running it to the card's edges. |
Card.Body
No props of its own beyond the common ones.
Card.Header
No props of its own beyond the common ones.
Card.Title
| Prop | Type | Default | Description |
|---|---|---|---|
| level | 1 | 2 | 3 | 4 | 5 | 6 | 3 | The heading level, for the page's outline. |
Card.Description
No props of its own beyond the common ones.
Card.Action
No props of its own beyond the common ones.
Card.Content
No props of its own beyond the common ones.
Card.Footer
No props of its own beyond the common ones.