# Card (@limerdev/zest) A surface that groups related content: `` 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`. - Category: Layout - Import: `import { Card, cardVariants } from '@limerdev/zest'` - Exports: `Card.Root`, `Card.Figure`, `Card.Body`, `Card.Header`, `Card.Title`, `Card.Description`, `Card.Action`, `Card.Content`, `Card.Footer`, `cardVariants` - Use for: A block of a page about one thing: a customer's details, a summary figure, a settings section, an item in a grid, a product or article with its image. - Don't: Cards inside cards, or a card around a whole page: use spacing and `Separator`. A clickable card: put a link or button inside it instead of making the card the target. ```svelte Acme AB Customer since 2021 12 open invoices, 48 200 kr due. ``` Props of `Card.Root`: - `layout` (`"horizontal" | "vertical" | "responsive" | "overlay"`, default `'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 `'default'`): The padding, the gaps and the title's size. - `variant` (`"outline" | "default" | "dash" | "soft"`, default `'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`). Props of `Card.Figure`: - `inset` (`boolean`, default `false`): Pad the figure and round the image, instead of running it to the card's edges. Props of `Card.Title`: - `level` (`1 | 2 | 3 | 4 | 5 | 6`, default `3`): The heading level, for the page's outline. Example: Image A figure that runs to the card's edges, a header with a badge, and actions. ```svelte Hills at sunset Autumn retreat 14–16 October, Åre Booked Three days, 24 people. The invoice goes out on 1 October. ``` Example: Header and actions No figure: a header with a title, description and an action; content; a footer. ```svelte Acme AB Customer since 2021 12 open invoices, 48 200 kr due. ``` Example: Variants variant: a border and shadow (default), a border only, a dashed border, a soft fill. ```svelte
{#each variants as variant (variant)} {variant} variant="{variant}" {/each}
``` Example: Sizes size: the padding, the gaps and the title. ```svelte
{#each sizes as size (size)} Size {size} size="{size}" Padding and gaps follow the size. {/each}
``` Example: Side layout="horizontal" puts the figure beside a Card.Body; "responsive" does so from md. ```svelte
A lake below mountains Lakeside office Room for 12, from 1 March Desks, two meeting rooms and a kitchen. Green fields Inset figure Padded, with rounded corners; beside the text from md.
``` Example: Overlay layout="overlay": the figure is the background, with a scrim behind the text. ```svelte Spring kick-off The whole company, 3 April ``` Example: Figures Summary figures in a grid of small cards: only a header and content. ```svelte
{#each figures as figure (figure.label)} {figure.label} {figure.change} {figure.value} {/each}
```