Layout · astro-ui · Card

Card

Content container with named-slot header/content/footer composition.

Card composes through named slots — header, default content, footer — and renders a semantic <article>. Four variants, six sizes, optional split dividers and a scrollable body. Prefer slots over title/description props.

Features

  • Named-slot composition: header / default / footer
  • 4 variants: default, outline, ghost, bordered
  • 6 sizes: xs → 2xl
  • split dividers, scrollable body
  • Semantic <article>, overridable with as
  • title/description props as a text-only shortcut

Usage

---
import { Card, Button } from "astro-ui";
---

<Card>
  <h3 slot="header">Title</h3>
  <p>Body content.</p>
  <div slot="footer"><Button size="sm">Action</Button></div>
</Card>

Demos

Basic

Default card

Header, content and footer compose through slots.

<Card>
  <h3 slot="header">Default card</h3>
  <p>Header, content and footer compose through slots.</p>
  <div slot="footer"><Button size="sm">Confirm</Button></div>
</Card>

Variants

Outline — flat surface.

Ghost card.

Bordered.

<Card variant="outline"><p>Outline — flat surface.</p></Card>
<Card variant="ghost"><p>Ghost card.</p></Card>
<Card variant="bordered"><p>Bordered.</p></Card>

Split & sizes

Split dividers

Borders separate header, content, and footer.

Small card.

<Card split>
  <h3 slot="header">Split dividers</h3>
  <p>Borders separate header, content, and footer.</p>
</Card>
<Card size="sm"><p>Small card.</p></Card>

API

Props

PropTypeDefaultDescription
as"article" | "section" | "div""article"Semantic wrapper element.
variant"default" | "outline" | "ghost" | "bordered""default"Surface style.
size"xs" | "sm" | "md" | "lg" | "xl" | "2xl""md"Padding/radius scale.
splitbooleanfalseDividers between header, content, footer.
scrollablebooleantrueScrollable body when content overflows.
title / descriptionstring—Text-only shortcut props.
classstring—Merged via cn(); Tailwind classes welcome.
idstring—Element id.
ariaLabelstring—Accessible name.

Slots

SlotDescription
headerCard header (your own heading element).
defaultBody content.
footerFooter actions.

Accessibility

Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.

  • aria-labelledby / aria-describedby wire the title and description to the card region
  • aria-label fallback for cards without a visible title

FAQ

Slots or title prop?

Slots — they keep your heading hierarchy and allow rich content. title/description exist only for trivial text-only cards.

Changelog

Version history mentioning Card.

v0.1.0 — 2026-11-11
added
  • Layout (7): Card, AspectRatio, ScrollArea, Separator, Accordion, Collapsible, StickySurface.
  • Missing semantic tokens: --ui-card, --ui-backdrop, --ui-backdrop-strong, --ui-progress-stripe, --ui-shadow-color, --ui-rating-1…5, --ui-text-3xl, --ui-space-0-5, --ui-space-7, and --ui-transition-delay.