Card
One thing among several of its kind (a project, a plan, a template) shown as a box with its name, a line about it and a few facts.
import { Card, CardSkeleton } from '@sypnia/ui/react'
Cards that open something
Projects in a grid. Each card is one link.
Code
import { Badge, Card, Status } from '@sypnia/ui/react';
// With href the whole card is the link: one target, easy to hit.
export default function Links() {
return (
<div className="sy-grid">
<Card title="Storefront" href="#storefront" meta={<><Status tone="ok">Healthy</Status><span>Frankfurt</span></>}>5 tables · 5,552 rows</Card>
<Card title="Back office" href="#back-office" meta={<><Status tone="warn">Slow</Status><span>Frankfurt</span></>}>12 tables · 48,210 rows</Card>
<Card title="Catalogue" href="#catalogue" meta={<><Badge outline>Read only</Badge><span>Virginia</span></>}>2 tables · 96 rows</Card>
</div>
);
} Cards that choose
Press one: the sentence under the grid follows.
The project will start from: Online store.
Code
import { useState } from 'react';
import { Card } from '@sypnia/ui/react';
const templates = [['Online store', 'Orders, customers and products.'], ['Bookings', 'Services, time slots and reservations.'], ['Blank', 'Start with no tables.']];
// With onClick the card is a button.
export default function Pressable() {
const [picked, setPicked] = useState('Online store');
return (
<div className="sy-stack">
<div className="sy-grid">
{templates.map(([name, text]) => <Card key={name} title={name} onClick={() => setPicked(name)}>{text}</Card>)}
</div>
<p className="sy-text--sm sy-text--soft" aria-live="polite">The project will start from: {picked}.</p>
</div>
);
} Cards that only show
Two plans, with no action of their own.
Code
import { Badge, Card } from '@sypnia/ui/react';
// Without href or onClick it is an article: it shows, it does not lead anywhere.
export default function Static() {
return (
<div className="sy-grid">
<Card title="Team plan" meta={<Badge tone="ok">Current</Badge>}>5 members, 5 GB of storage and backups kept for 7 days.</Card>
<Card title="Pro plan" meta={<span>US$ 49 a month</span>}>25 members, 100 GB of storage and backups kept for 30 days.</Card>
</div>
);
} Skeleton
The real piece and its skeleton: the same box, so nothing moves when the data arrives.
Code
import type { CSSProperties } from 'react';
import { Card, CardSkeleton } from '@sypnia/ui/react';
// A project card while its name and numbers load. The skeleton has the same box as the real one, so nothing moves when the data arrives.
export default function Skeleton() {
return (
<div className="sy-grid" style={{ '--min': '16rem' } as CSSProperties}>
<Card title="storefront" meta="Updated 2 hours ago">The shop of Northwind: orders, customers and products.</Card>
<CardSkeleton lines={1} />
</div>
);
} When to use it
Use it when
- A set of things to browse and open: projects, templates, plans. Lay them out in a grid.
- The whole card leads to the thing: pass
href. It chooses something in place:onClick. - Two or three facts in
meta: a state, a place, a date.
Do not use it when
- The things are compared by column or there are many: a Table reads better and paginates.
- It frames a region of the page with its own actions: that is a Panel.
- It would have buttons inside a card that is itself a link: one card, one target.
For everyone
- With
hrefit is one link named by all its text; withonClickone button; otherwise an article. - The whole surface is the target, far larger than 44 px.
- Hover lifts it slightly; keyboard focus shows the ring. Neither is the only sign that it can be pressed: the title reads as a destination.
Props
| Card | Type | Default |
|---|---|---|
titlerequired | ReactNode | |
className | string | |
href | string | |
meta | ReactNode | |
onClick | (() => void) |
| CardSkeleton | Type | Default |
|---|---|---|
lines | number | 2 |
meta | boolean | true |