Card
A bordered surface that groups related content under one title, with an optional description and footer actions.
Revisar contestação
Processo 0001234-56.2024.8.26.0100
Confira os argumentos de defesa antes de enviar ao revisor.
<Card size="default" variant="outlined" />When to use
- To group content that belongs to one subject: a task, a process, a customer.
- To set a block apart from the page so people can scan it, which follows Structure you can scan in the manifesto.
- To list comparable items, such as tasks or documents, each in its own card.
- To make a whole item selectable or clickable, with
interactiveorselected.
When not to use
- A lone block of text or a section of a page. Use plain spacing and a heading. A border adds noise when there is nothing to separate.
- Cards inside cards. Use a
Separatorto divide the content, or spacing. - A card that is only a button. Use Card button, which already has the right focus and hover behavior.
- Choosing between a few options. Use
Tileor Radio card, which carry a real checkbox or radio. - A message about something that just happened. Use an Alert.
Anatomy
A card is built from parts. Use the ones the content needs, in this order.
| Part | Role |
|---|---|
Card |
The surface. Sets the variant and the size for every part inside it. |
CardHeader |
Groups the title and the description. |
CardTitle |
Names the card. Renders an h3. |
CardDescription |
One line of context under the title. |
CardContent |
The body. |
CardFooter |
The actions, in a row. Put the main action last, which keeps one clear next step. |
Contestação
Cliente: Banco Aurora
Revisor: Marina Costa. Prazo para protocolo em 12/12/2026.
Variants
Flat
Prazo: 12/12/2026
Contestação aguardando revisão.
Outlined
Prazo: 12/12/2026
Contestação aguardando revisão.
| Variant | Use for |
|---|---|
outlined |
Default. Cards on a page, with a border and radius. |
flat |
Cards on a surface that already has a border or fill. |
Sizes
Compact
Processo 0001234-56.2024.8.26.0100
Petição inicial anexada.
Default
Processo 0001234-56.2024.8.26.0100
Petição inicial anexada.
| Size | Use for |
|---|---|
default |
Pages and panels. The parts add their own padding. |
compact |
Dense lists. The card pads itself with 20px and the parts drop their padding, and the title uses the smaller labelSm style. |
States
Padrão
Só leitura
Interativo
Borda realça ao passar o mouse
Selecionado
Revisor responsável
interactiveadds a border color change on hover (only for devices with a mouse) and a focus ring while a control inside has focus. The card itself is not focusable: put a button or link inside, or useasChild.selecteddraws a primary border and an accent fill. Pair it with a real radio or checkbox, because the style alone tells assistive technology nothing.
Content
- The title says what the card is: “Revisar contestação”, not “Detalhes”.
- The description adds a fact people use to tell cards apart, such as the process number.
- One primary button per card. Supporting actions use
secondaryorghost. - Keep a card short enough to read at a glance. If it needs a scroll, split it into two cards or move the rest to a details view.
Do and don’t
Dados do processo
Número: 0001234-56.2024.8.26.0100
Vara: 3ª Vara Cível
Dados do processo
Número: 0001234-56.2024.8.26.0100
Vara: 3ª Vara Cível
Accessibility
- A card is a plain
div. It has no role, so it is not announced as a group. Addrole="group"andaria-labelledbypointing to theCardTitlewhen the grouping matters. CardTitlerenders anh3. Place cards under anh2so the heading order stays correct.interactiveonly changes the look. Keyboard access comes from the control inside, andfocus-withinshows the ring on the card while that control has focus.- Do not rely on
selectedalone to show state. Use a realinputorrole="radio"/role="checkbox"inside the card. - The hover style is wrapped in
(hover: hover) and (pointer: fine), and the transition respectsprefers-reduced-motion.
Code
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@repo/ui/card";
import { Button } from "@repo/ui/button";
<Card>
<CardHeader>
<CardTitle>Revisar contestação</CardTitle>
<CardDescription>Processo 0001234-56.2024.8.26.0100</CardDescription>
</CardHeader>
<CardContent>Confira os argumentos de defesa antes de enviar.</CardContent>
<CardFooter className="gap-2">
<Button variant="secondary">Ver documento</Button>
<Button variant="primary">Enviar para revisão</Button>
</CardFooter>
</Card>;
Props
Card| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Renders the child element with card styles, using Radix Slot |
interactive | boolean | false | Adds a hover border and a focus ring. Use it when the card sits inside a focusable trigger |
selected | boolean | false | Marks the card as selected with a primary border and an accent fill. Pair it with a real radio or checkbox |
size | "compact" | "default" | default | Spacing density. `compact` pads the card itself and removes the padding of its parts |
variant | "flat" | "outlined" | outlined | Border and corner radius |
CardHeader, CardContent, CardFooter, CardDescription| Prop | Type | Default | Description |
|---|---|---|---|
ref | Ref<HTMLDivElement> | — | Passed straight to the element. React 19 ref prop. |
CardHeader, CardTitle, CardDescription, CardContent and CardFooter take only standard element props and className. They read size from the nearest Card, so they cannot be given a size of their own. CardTitle is always an h3.
Known issues
| Issue | Effect |
|---|---|
The border is border-tertiary, which is the stroke-tertiary token at 5% opacity. The flat variant has no border at all. |
The repository rule is solid backgrounds with borders. A flat card is a fill with no edge, and the outlined edge is very faint on the page background, so cards are hard to tell apart on older, low-contrast monitors. |
interactive uses focus-within:ring-ring, but the preset has no ring color (only old-ring). |
The focus ring falls back to Tailwind’s default translucent blue instead of the focus token. |
With size="default" the card itself has no padding; only CardHeader, CardContent and CardFooter add it. |
Text placed directly in a Card touches the border. Use the parts, or size="compact". |
CardTitle always renders as="h3" and its props type does not accept as. |
The heading level cannot be changed, which can break the heading order on a page. |
selected and interactive are styles only. |
A card marked selected without a real control inside tells screen readers nothing. |