Skip to main content

Card

Group related content and actions on a neutral surface.

Team Subscription

Manage billing and team seat limits.

Pro Plan

Your team has 8 active seats out of 10 available. Upgrade to Enterprise for unlimited seats and SSO integration.

$49 / month
Props
Slots

Anatomy#

Card [component; slot=root]
├── Card.Header [part; slot=header]
│   ├── Card.Title [part; slot=title]
│   ├── Card.Description [part; slot=description]
│   └── Card.Action [part; slot=action]
├── Card.Body [part; slot=body]
└── Card.Footer [part; slot=footer]

Usage#

Use Card to group related content and actions on a neutral surface. Its parts are structural and add no interactive behavior or ARIA relationships. The root, Card.Title, and the other parts render a div by default (Card.Description renders a p); set as to change the element, such as a heading for the title or article for the root.

import { Card } from 'moraine'

export function Example() {
  return (
    <Card>
      <Card.Header>
        <Card.Title>Project</Card.Title>
      </Card.Header>
      <Card.Body>Project details</Card.Body>
    </Card>
  )
}

Variants and sizes#

Every variant has an outer border, and the header looks the same as the body. outline (default) adds a top border to the footer. subtle adds the footer divider and a muted footer background. none keeps only the outer border and the part spacing. The sm, md (default), and lg sizes change the density of the header, body, footer, title, and description together. Set variant and size on Card; the parts inherit them.

<Card variant="subtle" size="sm">
  <Card.Header>
    <Card.Title as="h2">Seats</Card.Title>
    <Card.Description>8 of 10 used</Card.Description>
  </Card.Header>
</Card>

Parts#

Compose the parts you need inside Card. Header and body provide horizontal insets, while the root spaces the sections. Direct children can still span the card’s full width. Place a control for the whole card in Card.Action, which sits at the end of the header beside the title and description. Place other actions in Card.Footer.

<Card>
  <Card.Header>
    <Card.Title as="h2">Invoice</Card.Title>
    <Card.Action>
      <Button size="sm">Download</Button>
    </Card.Action>
  </Card.Header>
  <Card.Body>Due 12 May</Card.Body>
  <Card.Footer>
    <Button>Pay</Button>
  </Card.Footer>
</Card>

Examples#

Deploy a project from a summary card#

Pair a heading, description, and footer actions when the card is the decision surface.

import { Button, Card } from 'moraine'

export function CardStructure() {
  return (
    <Card class="max-w-sm w-full">
      <Card.Header>
        <Card.Title as="h3">Project Deployment</Card.Title>
        <Card.Description>Configure automated build triggers.</Card.Description>
      </Card.Header>
      <Card.Body>
        <p class="text-sm text-muted-foreground">
          Deployments are pushed directly to the globally distributed edge CDN network.
        </p>
      </Card.Body>
      <Card.Footer class="gap-2 justify-end">
        <Button variant="ghost" size="xs">
          Cancel
        </Button>
        <Button size="xs">Deploy</Button>
      </Card.Footer>
    </Card>
  )
}

Publish a release announcement#

Card does not choose a heading level. Set as on Card.Title to the level that fits the page, such as h2, and set as="article" on Card when the card is a standalone story.

import { Badge, Card } from 'moraine'

export function CardSemantics() {
  return (
    <Card as="article" class="max-w-sm w-full">
      <Card.Header>
        <Card.Title as="h3">Release v2.4.0 Available</Card.Title>
        <Card.Description>Published 2 hours ago by @release-bot</Card.Description>
        <Card.Action>
          <Badge>New</Badge>
        </Card.Action>
      </Card.Header>
      <Card.Body>
        <p class="text-sm text-muted-foreground">
          Includes performance optimizations, smaller bundle sizes, and refreshed component styles.
        </p>
      </Card.Body>
    </Card>
  )
}

Place media directly inside Card to span its width. Clip overflow on the root with overflow-hidden only if the image must follow the card radius.

import { Button, Card } from 'moraine'

export function WithImage() {
  return (
    <Card class="max-w-sm w-full overflow-hidden">
      <img
        src="https://images.unsplash.com/photo-1604076850742-4c7221f3101b?q=80&w=1887&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
        alt="Landscape by mymind on Unsplash"
        class="w-full aspect-video object-cover brightness-60 grayscale"
      />
      <Card.Body>
        <Card.Title as="h3">Beautiful Landscape</Card.Title>
        <Card.Description class="mt-1">
          A full-bleed image can sit directly inside Card.
        </Card.Description>
      </Card.Body>
      <Card.Footer>
        <Button class="w-full">Open</Button>
      </Card.Footer>
    </Card>
  )
}

Save meeting notes#

Put a header action next to the title when the command belongs to the whole record, not the footer.

import { Button, Card } from 'moraine'

export function HeaderAction() {
  return (
    <Card class="w-lg">
      <Card.Header>
        <Card.Title as="h3">Meeting Notes</Card.Title>
        <Card.Description>Transcript summary from the latest client sync.</Card.Description>
        <Card.Action>
          <Button size="sm" variant="soft" tone="neutral">
            Transcribe
          </Button>
        </Card.Action>
      </Card.Header>
      <Card.Body>
        <ol class="text-sm pl-5 list-decimal opacity-85 flex flex-col gap-1.5">
          <li>Dashboard redesign should prioritize mobile layouts.</li>
          <li>Timeline target is six weeks with weekly milestones.</li>
          <li>Next review meeting is scheduled for Tuesday morning.</li>
        </ol>
      </Card.Body>
      <Card.Footer class="justify-end">
        <Button size="sm" variant="outline">
          Dismiss
        </Button>
        <Button size="sm">Save</Button>
      </Card.Footer>
    </Card>
  )
}

Warn about storage usage#

Replace Title and Description with custom header markup when the headline is a metric rather than a label.

import { Card } from 'moraine'

export function CustomHeader() {
  return (
    <Card class="max-w-sm">
      <Card.Header class="flex items-center justify-between">
        <div>
          <p class="text-xs text-muted-foreground">Storage</p>
          <p class="text-2xl font-semibold">72%</p>
        </div>
        <span class="text-xs text-success font-medium">12 GB free</span>
      </Card.Header>
      <Card.Body>
        <p class="text-sm text-muted-foreground">Archive old uploads to reclaim more space.</p>
      </Card.Body>
    </Card>
  )
}

API Reference#

Props#

Card#

Props for Card. Renders a <div> element by default.

Prop

Header#

Renders a <div> element by default.

Prop

Title#

Renders a <div> element by default.

Prop

Description#

Renders a <p> element by default.

Prop

Action#

Renders a <div> element by default.

Prop

Body#

Renders a <div> element by default.

Prop

Renders a <div> element by default.

Prop