Card
A card groups related content, such as one release or one document, on its own surface.
When to use
Section titled “When to use”- Use it for a self-contained item with a title and, often, actions.
- Use plain sections, not cards, to split one long form or page.
- Don’t nest cards inside cards.
Do and don’t
Section titled “Do and don’t”Anatomy
Section titled “Anatomy”- 1Header: title and description
- 2Content
- 3Footer with actions
Header (title, description, optional action), content, then footer with actions. The card sits on card with a border and radius-lg (12px). It has no shadow by default: a border separates it from the page. Add shadow-md only for a card that floats, such as the header card of the dashboard.
Variants
Section titled “Variants”There is one style. Pass shadow-md for a floating card.
| React | Vue | Flutter | Type | Default | Use |
|---|---|---|---|---|---|
CardHeader, CardTitle, CardDescription |
same names | title, description |
element | none | The heading area. |
CardContent |
CardContent |
child |
element | none | The body. |
CardFooter |
CardFooter |
footer |
element | none | Actions. |
className |
class |
width, padding |
string | none | Size and floating shadow. |
import { Button } from "@/components/ui/button"import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle,} from "@/components/ui/card"
export default function CardDemo() { return ( <Card className="w-full max-w-sm"> <CardHeader> <CardTitle>Rilis baru</CardTitle> <CardDescription>Single "Senja di Kota" siap dikirim ke semua platform.</CardDescription> </CardHeader> <CardContent> <p className="text-sm text-muted-foreground">Periksa metadata dan artwork sebelum kamu kirim.</p> </CardContent> <CardFooter className="gap-2"> <Button>Kirim</Button> <Button variant="outline">Periksa dulu</Button> </CardFooter> </Card> )}<script setup lang="ts">import { Button } from "@/components/ui/button"import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle,} from "@/components/ui/card"</script>
<template> <Card class="w-full max-w-sm"> <CardHeader> <CardTitle>Rilis baru</CardTitle> <CardDescription>Single "Senja di Kota" siap dikirim ke semua platform.</CardDescription> </CardHeader> <CardContent> <p class="text-sm text-muted-foreground">Periksa metadata dan artwork sebelum kamu kirim.</p> </CardContent> <CardFooter class="gap-2"> <Button>Kirim</Button> <Button variant="outline">Periksa dulu</Button> </CardFooter> </Card></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
class CardDemo extends StatelessWidget { const CardDemo({super.key});
@override Widget build(BuildContext context) { final theme = ShadTheme.of(context); return ShadCard( width: 384, title: Text('Rilis baru', style: theme.textTheme.h4), description: const Text('Single "Senja di Kota" siap dikirim ke semua platform.'), footer: Row( children: [ ShadButton(onPressed: () {}, child: const Text('Kirim')), const SizedBox(width: 8), ShadButton.outline(onPressed: () {}, child: const Text('Periksa dulu')), ], ), child: const Padding( padding: EdgeInsets.symmetric(vertical: 16), child: Text('Periksa metadata dan artwork sebelum kamu kirim.'), ), ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/card.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/card.jsonAccessibility
Section titled “Accessibility”- A card is a plain container; give its title a real heading level in your page when it starts a section.
- Keep one main action per card, so the footer reads clearly.
