CardGrid
Cards side by side that wrap into rows: as many columns as fit, one on phones. It holds Card, NewCard, ActionCard or PlanCard.
import { CardGrid, CardGridSkeleton } from '@sypnia/ui/react'
Projects
Code
import { Badge, Card, CardGrid, NewCard } from '@sypnia/ui/react';
// As many columns as fit; one on phones. With a label the grid is a list of projects.
export default function Projects() {
return (
<CardGrid label="Projects" min="14rem">
<Card title="Shop" href="#shop" meta={<><Badge tone="ok" dot>Live</Badge><span>14 tables</span></>}>Orders, products and customers.</Card>
<Card title="Blog" href="#blog" meta={<span>3 tables</span>}>Posts and comments.</Card>
<Card title="Operations" href="#ops" meta={<><Badge tone="warn" dot>Paused</Badge><span>8 tables</span></>}>Stock and suppliers.</Card>
<NewCard onClick={() => {}}>New project</NewCard>
</CardGrid>
);
} In Astro
Code
---
// The Astro twin: with `label` it is a list, so each card goes in an <li>.
import CardGrid from '@sypnia/ui/astro/CardGrid.astro';
import Card from '@sypnia/ui/astro/Card.astro';
---
<CardGrid label="Guides" min="14rem">
<li><Card title="Quick start" href="#q">Your first error, in five minutes.</Card></li>
<li><Card title="Self-hosting" href="#s">Run it on your own servers.</Card></li>
<li><Card title="The agent" href="#a">How fixes are written.</Card></li>
</CardGrid> Skeleton
Code
import { CardGridSkeleton } from '@sypnia/ui/react';
// The grid while its cards load: the same columns, each card with its lines.
export default function Skeleton() {
return <CardGridSkeleton items={3} lines={1} min="14rem" />;
} When to use it
Use it when
- Projects, guides, plans.
- Give it a
labelwhen the cards are a list of things.
Do not use it when
- Records with fields: DataCards draws them for you.
For everyone
- With a label it is a list, so screen readers say how many there are.
Props
| CardGrid | Type | Default |
|---|---|---|
labelA name for screen readers, when the grid is a list of things. | string | |
minThe narrowest a card gets before the grid has one column fewer. | string | 16rem |
| CardGridSkeleton | Type | Default |
|---|---|---|
items | number | 3 |
lines | number | 2 |
min | string | 16rem |