Data display
Card
A block of content with a title, description, action and footer. With href the whole card is one link, and buttons inside still work. The title is an h3; headingLevel changes it. density="compact" is for dense records: p-4 in place of p-6, a text-base title and a smaller header gap. With onSelect the whole card is one button instead (a pickable tile: a product, a template, a choice); the title is its text, 2 lines at most with the full text in title. disabled dims it and stops the press (a sold-out product). media puts an image above the header at the full width of the card, for example <Thumbnail size="fill" />.
import { Card } from "@percentsa/ui";Examples
Masar
Booking app for clinics
Mobile
12,400 bookings in the first month.
Live
Code
export function CardExample() {
const t = useT();
return (
<Grid min="14rem" gap={4} className="w-full">
<Card
title={t("Masar", "مسار")}
description={t("Booking app for clinics", "تطبيق حجوزات للعيادات")}
action={<Badge>{t("Mobile", "جوال")}</Badge>}
footer={<StatusDot status="live">{t("Live", "يعمل")}</StatusDot>}
>
<Text size="sm" tone="muted">{t("12,400 bookings in the first month.", "12,400 حجز في الشهر الأول.")}</Text>
</Card>
<Card
href="#"
title={t("Sadeem dashboard", "لوحة سديم")}
description={t("The whole card is one link. The copy button still works.", "البطاقة كلها رابط واحد. وزر النسخ يعمل أيضًا.")}
action={<CopyButton value="https://percent.sa" iconOnly />}
footer={t("Updated 2 days ago", "حُدّثت قبل يومين")}
/>
</Grid>
);
}
/** A form table: `scope="row"` for the line labels (the look of a body cell), `wrap` for long column titles. */Default
p-6, title text-lg.
The usual card.
Compact
p-4, title text-base.
For dense records.
Code
export function CardCompactExample() {
const t = useT();
return (
<Grid min="14rem" gap={4} className="w-full">
<Card title={t("Default", "افتراضي")} description={t("p-6, title text-lg.", "حشوة p-6، والعنوان text-lg.")}>
<Text size="sm" tone="muted">{t("The usual card.", "البطاقة المعتادة.")}</Text>
</Card>
<Card density="compact" title={t("Compact", "مضغوط")} description={t("p-4, title text-base.", "حشوة p-4، والعنوان text-base.")}>
<Text size="sm" tone="muted">{t("For dense records.", "للسجلات الكثيفة.")}</Text>
</Card>
</Grid>
);
}
/** A dense list: `density="compact"`, a muted line under the customer (a phone, with a link in it), and the card slots below 768 px. */Pick a product.
Code
export function CardPickExample() {
const t = useT();
const [picked, setPicked] = useState<string>();
return (
<div className="grid w-full gap-3">
<Grid min="11rem" gap={3}>
{PRODUCTS.map((p) => (
<Card
key={p.id}
density="compact"
media={<Thumbnail src={PADS} alt="" size="fill" />}
title={t(p.en, p.ar)}
description={<span dir="ltr">{p.id.toUpperCase()}</span>}
disabled={p.stock <= 0}
onSelect={() => setPicked(t(p.en, p.ar))}
>
<div className="flex flex-wrap items-center justify-between gap-2">
<Money amount={p.price} />
<StatusBadge tone={p.stock > 0 ? "success" : "neutral"}>{p.stock > 0 ? t(`In stock: ${p.stock}`, `متوفر: ${p.stock}`) : t("Out of stock", "نفد")}</StatusBadge>
</div>
</Card>
))}
</Grid>
<Text size="sm" tone="muted" aria-live="polite">
{picked ? t(`Added: ${picked}`, `أُضيف: ${picked}`) : t("Pick a product.", "اختر منتجًا.")}
</Text>
</div>
);
}