Card

Card is a container component that groups and displays related content. It organizes information with a header, content, and footer structure, supporting diverse layouts including images and actions.

3
Variants
3
Sizes
2
Orientations
Pure
React

Playground

Preview
D

Card Title

Card description goes here.

This is the main content area of the card. It can contain any content.

Variant
Size
Radius
Direction
Options
<Card>
  <Card.Header>
    <Card.Title icon={<Layers />}>Card Title</Card.Title>
    <Card.Description>Card description goes here.</Card.Description>
  </Card.Header>
  <Card.Content>
    <p className="text-sm text-text-muted">
      This is the main content area of the card. It can contain any content.
    </p>
  </Card.Content>
  <Card.Footer>
    <Button size="sm" variant="ghost" className="ml-auto" rightIcon={<ChevronRight />}>
      Learn more
    </Button>
  </Card.Footer>
</Card>

Variants

3 variants control the visual prominence of the card.

Default

Default

Elevated with shadow

Main UI
Outline

Outline

Flat style with border only

Lists & grids
Ghost

Ghost

Minimal — no background or border

Inside groups

Sizes

sm
Side16px
Top20px
Inner bottom12px
Last bottom20px
default
Side24px
Top24px
Inner bottom16px
Last bottom24px
lg
Side32px
Top32px
Inner bottom16px
Last bottom32px

Responsive: default and lg sizes automatically reduce padding one step on mobile (below 640px). sm size uses a fixed value.

Features

Orientation

Switch between vertical and horizontal layout. In horizontal mode, the image is placed on the left.

Vertical (Default)

Image Area

Vertical Card

Image on top, content below.

<Card>
  <Card.Image src="/placeholder.jpg" alt="Preview" />
  <Card.Header>
    <Card.Title>Vertical Card</Card.Title>
    <Card.Description>Image on top, content below.</Card.Description>
  </Card.Header>
</Card>

Horizontal

Preview

Horizontal Card

Image on left, content on right.

<Card direction="horizontal">
  <Card.Image src="/placeholder.jpg" alt="Preview" />
  <Card.Header>
    <Card.Title>Horizontal Card</Card.Title>
    <Card.Description>Image on left, content on right.</Card.Description>
  </Card.Header>
</Card>

Header Action

Notifications

You have 3 unread messages.

<Card>
  <Card.Header>
    <Card.Title>Notifications</Card.Title>
    <Card.Description>You have 3 unread messages.</Card.Description>
    <Card.Action>
      <DropdownMenu>
        <DropdownMenu.Trigger asChild>
          <IconButton variant="ghost" size="sm">
            <MoreHorizontal />
          </IconButton>
        </DropdownMenu.Trigger>
        <DropdownMenu.Content align="end">
          <DropdownMenu.Item>Edit</DropdownMenu.Item>
          <DropdownMenu.Item>Duplicate</DropdownMenu.Item>
          <DropdownMenu.Separator />
          <DropdownMenu.Item>Delete</DropdownMenu.Item>
        </DropdownMenu.Content>
      </DropdownMenu>
    </Card.Action>
  </Card.Header>
</Card>

Image Overlay

Beach

Tropical Beach

Discover the most beautiful beaches.

<Card variant="outline">
  <Card.Image
    src="https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=600&h=300&fit=crop"
    alt="Beach"
    overlay
    className="h-48"
  />
  <Card.Header>
    <Card.Title>Tropical Beach</Card.Title>
    <Card.Description>Discover the most beautiful beaches.</Card.Description>
  </Card.Header>
</Card>

Customization

Customize image overlays with overlayOpacity and overlayClassName.

Opacity control

Beach

Light (30%)

Beach

Default (60%)

Beach

Dark (80%)

<Card.Image overlay overlayOpacity={30} /> {/* Light */} <Card.Image overlay /> {/* Default 60% */} <Card.Image overlay overlayOpacity={80} /> {/* Dark */}

Full customization

{/* Change gradient direction */} <Card.Image overlay overlayClassName="from-black/60 bg-gradient-to-b" /> {/* Color overlay */} <Card.Image overlay overlayClassName="from-blue-900/50" />

Tip: Specifying overlayClassName takes precedence over overlayOpacity. Freely change the gradient direction or color.

API

Component Structure

Card— Radix Slot
.ImageProps.HeaderProps.TitleProps.DescriptionProps.ActionProps.ContentProps.FooterProps

Props

Card

variant"default"
"default" | "outline" | "ghost"

Visual style of the card

size"default"
"sm" | "default" | "lg"

Content padding scale (responsive)

radius"xl"
"sm" | "base" | "md" | "lg" | "xl" | "2xl"

Corner radius (2/4/6/8/12/16px)

direction"vertical"
"vertical" | "horizontal"

Layout direction

interactivefalse
boolean

Enhanced shadow and lift effect on hover (for clickable cards)

asChildfalse
boolean

Render as child element via Slot pattern

Card.Title

iconundefined
React.ReactNode

Icon displayed before the title

Card.Image

overlayfalse
boolean

Show gradient overlay

overlayOpacity60
number

Overlay opacity (10–90)

overlayClassNameundefined
string

Custom class for overlay (takes precedence over overlayOpacity)

alt""
string

Alternative text for the image

Card.Header / Card.Content / Card.Footer / Card.Action / Card.Description

Inherits standard HTMLDivAttributes (Card.Description inherits HTMLParagraphAttributes). Padding is automatically adjusted based on the card's size context.

Anatomy

1
2
3
4
5
Card Title
6
Short description text here
7
8
Cancel
Confirm
Padding X24px
Padding top24px
Radius12px(xl)
1
Root
Card
2
Image
Card.Image
3
Header
Card.Header
4
Icon
Card.Title icon
5
Title
Card.Title
6
Action
Card.Action
7
Content
Card.Content
8
Footer
Card.Footer

Best Practices

Recommended

  • Group related content into a single card
  • Use consistent variant and size within the same section
  • Use the interactive prop for clickable cards
  • Always set the alt attribute on images

Don't

  • Don't nest cards inside cards
  • Don't cram excessive content into one card
  • Don't place buttons or links inside interactive cards (click conflicts)
  • Don't use cards purely for layout purposes

Accessibility

Semantics

asChildUse <a> for link cards
h3Card.Title renders as an h3 element

ARIA / WCAG

  • Icon in Card.Title has aria-hidden="true"
  • Card.Image supports the alt attribute
  • Use heading hierarchy (h3) correctly
  • DOM order matches visual order