Documentation / Layout
Card
A visual container to group content and its actions: a summary, a product sheet, a setting. Card carries the shell (variant, size, corners), and its separately exported sub-components are composed inside it: CardImage, CardHeader, CardTitle, CardDescription, CardBody and CardFooter.
size caps the maximum width (max-w-sm / md / 2xl); the inner padding is carried by the sub-components, not by the card. No hooks: the component renders on the server. With clickable, the card stays a div — for navigation, prefer a link inside it.
Examples
Basic usage
A header with a title and a description, a body, a footer of actions.
import { Button, Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle } from "@synertech/ui";
export function Basic() {
return (
<Card>
<CardHeader>
<CardTitle>Rapport mensuel</CardTitle>
<CardDescription>Synthèse de l’activité d’octobre</CardDescription>
</CardHeader>
<CardBody>
<p className="text-sm text-gray-700 dark:text-gray-300">
Le chiffre d’affaires progresse de 12 % par rapport à septembre.
</p>
</CardBody>
<CardFooter align="right">
<Button size="sm">Ouvrir le rapport</Button>
</CardFooter>
</Card>
);
}Variants
default (border), outlined (thick border, transparent background), elevated (shadow) and filled (grey background).
import { Card, CardBody, CardDescription, CardTitle } from "@synertech/ui";
export function Variants() {
const variants = ["default", "outlined", "elevated", "filled"] as const;
return (
<div className="grid grid-cols-2 gap-4">
{variants.map((variant) => (
<Card key={variant} variant={variant} size="sm">
<CardBody>
<CardTitle size="sm">{variant}</CardTitle>
<CardDescription>Variante « {variant} »</CardDescription>
</CardBody>
</Card>
))}
</div>
);
}Product sheet with an image
CardImage enforces a ratio (video, square, wide) and crops the image.
import { Button, Card, CardBody, CardDescription, CardFooter, CardImage, CardTitle, Chip } from "@synertech/ui";
export function WithImage() {
return (
<Card size="sm" variant="elevated" hoverable>
<CardImage
src="https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=600"
alt="Casque audio sur fond jaune"
aspectRatio="video"
/>
<CardBody>
<div className="flex items-center justify-between">
<CardTitle size="sm">Casque sans fil</CardTitle>
<Chip label="Nouveau" color="success" variant="soft" size="sm" />
</div>
<CardDescription className="mt-1">
Réduction de bruit active, 30 h d’autonomie.
</CardDescription>
</CardBody>
<CardFooter divider align="between">
<span className="font-semibold text-gray-900 dark:text-white">149,00 €</span>
<Button size="sm">Ajouter au panier</Button>
</CardFooter>
</Card>
);
}Header actions and dividers
actions sits to the right of the title; divider draws a line under the header or above the footer.
import { Button, Card, CardBody, CardHeader, CardTitle } from "@synertech/ui";
export function HeaderActions() {
return (
<Card size="lg">
<CardHeader divider actions={<Button size="sm">Modifier</Button>}>
<CardTitle as="h2">Informations du compte</CardTitle>
</CardHeader>
<CardBody padding="lg">
<dl className="grid grid-cols-2 gap-2 text-sm">
<dt className="text-gray-500">Nom</dt>
<dd>Claire Martin</dd>
<dt className="text-gray-500">E-mail</dt>
<dd>claire.martin@exemple.fr</dd>
</dl>
</CardBody>
</Card>
);
}Long title
The title shrinks beside the actions, which stay whole: with truncate on CardTitle, a title that is too long ends in an ellipsis instead of pushing the actions out of the card.
import { Badge, Card, CardBody, CardHeader, CardTitle } from "@synertech/ui";
export function LongTitle() {
return (
<Card className="max-w-xs">
<CardHeader actions={<Badge color="warning">En attente</Badge>}>
<CardTitle size="sm" className="truncate">
Migrer la facturation vers le nouveau fournisseur de paiement avant la fin du trimestre
</CardTitle>
</CardHeader>
<CardBody>
<p className="text-sm text-gray-600 dark:text-gray-300">Échéance : 31 mars</p>
</CardBody>
</Card>
);
}Selectable card
hoverable signals interactivity; a real radio button inside the card makes it keyboard-usable, which clickable alone does not.
import { useState } from "react";
import { Card, CardTitle } from "@synertech/ui";
export function Selectable() {
const plans = ["Essentiel", "Pro", "Entreprise"];
const [selected, setSelected] = useState("Pro");
return (
<fieldset className="flex gap-4">
<legend className="sr-only">Offre</legend>
{plans.map((plan) => (
<Card
key={plan}
size="sm"
variant="outlined"
hoverable
borderColor={plan === selected ? "border-blue-600" : undefined}
>
<label className="flex cursor-pointer items-center gap-3 p-4">
<input
type="radio"
name="plan"
checked={plan === selected}
onChange={() => setSelected(plan)}
/>
<CardTitle size="sm" as="h4">
{plan}
</CardTitle>
</label>
</Card>
))}
</fieldset>
);
}API reference
Components
import { Card } from "@synertech/ui";Props — CardProps
| Prop | Type | Default | Description |
|---|---|---|---|
as |
"article" | "section" | "div" |
"div" |
|
bgColor |
string |
— | |
borderColor |
string |
— | |
children |
ReactNode |
— | |
clickable |
boolean |
false |
|
hoverable |
boolean |
false |
|
padding |
"none" | "sm" | "md" | "lg" |
"none" |
|
rounded |
"none" | "sm" | "md" | "lg" | "xl" | "full" |
"lg" |
|
shadowColor |
string |
— | |
size |
"sm" | "md" | "lg" |
"md" |
|
variant |
"default" | "outlined" | "elevated" | "filled" |
"default" |
+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
import { CardBody } from "@synertech/ui";Props — CardBodyProps
| Prop | Type | Default | Description |
|---|---|---|---|
children |
ReactNode |
— | |
padding |
"none" | "sm" | "md" | "lg" |
"md" |
+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
import { CardDescription } from "@synertech/ui";Props — CardDescriptionProps
| Prop | Type | Default | Description |
|---|---|---|---|
children |
ReactNode |
— | |
size |
"sm" | "md" | "lg" |
"md" |
+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
import { CardFooter } from "@synertech/ui";Props — CardFooterProps
| Prop | Type | Default | Description |
|---|---|---|---|
align |
"left" | "center" | "right" | "between" |
"left" |
|
children |
ReactNode |
— | |
divider |
boolean |
false |
|
padding |
"none" | "sm" | "md" | "lg" |
"md" |
+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
import { CardHeader } from "@synertech/ui";Props — CardHeaderProps
| Prop | Type | Default | Description |
|---|---|---|---|
actions |
ReactNode |
— | |
children |
ReactNode |
— | |
divider |
boolean |
false |
|
padding |
"none" | "sm" | "md" | "lg" |
"md" |
+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
import { CardImage } from "@synertech/ui";Props — CardImageProps
| Prop | Type | Default | Description |
|---|---|---|---|
alt• |
string |
— | |
src• |
string |
— | |
aspectRatio |
"auto" | "square" | "video" | "wide" |
"auto" |
|
objectFit |
"cover" | "contain" | "fill" | "none" |
"cover" |
|
position |
"top" | "bottom" |
"top" |
+ 289 inherited native attributes from ImgHTMLAttributes, HTMLAttributes, AriaAttributes (className, id, aria-*, event handlers…).
import { CardTitle } from "@synertech/ui";Props — CardTitleProps
| Prop | Type | Default | Description |
|---|---|---|---|
as |
"h1" | "h2" | "h3" | "h4" | "h5" | "h6" |
"h3" |
|
children |
ReactNode |
— | |
size |
"sm" | "md" | "lg" |
"md" |
+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).