Cards group related content in a bordered, shadowed surface.
Setup
<script lang="ts">
import { Card, Button } from '.';
</script> Default card
Noteworthy technology acquisitions
Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.
<script lang="ts">
import { Card, Button } from '.';
</script>
<Card>
<div class="p-5">
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
Noteworthy technology acquisitions
</h5>
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">
Here are the biggest enterprise technology acquisitions of 2021 so far.
</p>
<Button>Read more</Button>
</div>
</Card> Card with image
Office content
Get started with a large variety of cards for your project.
<script lang="ts">
import { Card } from '.';
</script>
<Card img="/image.png" imgAlt="Office">
<div class="p-5">
<h5 class="mb-2 text-2xl font-bold">Office content</h5>
<p>Get started with a large variety of cards for your project.</p>
</div>
</Card> Horizontal card
Horizontal layout
Use horizontal for side-by-side image and content.
<script lang="ts">
import { Card } from '.';
</script>
<Card horizontal img="/image.png" size="md">
<div class="p-5">
<h5 class="mb-2 text-2xl font-bold">Horizontal layout</h5>
<p>Use horizontal for side-by-side image and content.</p>
</div>
</Card> Card as link
<script lang="ts">
import { Card } from '.';
</script>
<Card href="/docs" hoverable>
<div class="p-5">
<h5 class="mb-2 text-xl font-bold">Clickable card</h5>
<p>Pass href to render an anchor.</p>
</div>
</Card> Composition notes
- Without
href, the root is adiv; withhref, an anchor (hover styles apply automatically). imgrenders above (or beside whenhorizontal) thechildrencontent block.- Use
reverseto flip image/content order; combine withhorizontalfor RTL-style media.
Props
CardProps
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | — | Card body |
img | string | — | Image URL |
imgAlt | string | '' | Image alt text |
horizontal | boolean | false | Side-by-side image/content |
reverse | boolean | false | Reverse image/content order |
shadow | xs | sm | normal | md | lg | xl | 2xl | inner | none | md | Shadow size |
size | xs | sm | md | lg | xl | sm | Max width |
hoverable | boolean | false | Hover background |
href | string | — | Render as link |
classes | { base?, image? } | — | Theme slot class overrides |
class | ClassValue | — | Root classes |
…rest | div / anchor attrs | — | Forwarded to the root |
Snippets
| Snippet | Description |
|---|---|
children | Card content (typically padded text / actions) |