IndiaCN UI

Card

A flexible content container with header, body, footer, and image support.

Introduction

Cards are versatile containers for displaying grouped content. They support headers, footers, images, and various layout configurations.

Installation

import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card';

Usage

<Card>
<CardHeader>
  <CardTitle>Card Title</CardTitle>
  <CardDescription>Card description.</CardDescription>
</CardHeader>
<CardContent>
  <p>Card content goes here.</p>
</CardContent>
<CardFooter>
  <Button>Action</Button>
</CardFooter>
</Card>

Examples

Default

Card Title

Card description goes here.

Cards are flexible content containers. They include options for headers, footers, content, and images.

CardDefault
import { Button } from '@/components/ui/button';
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card';

export default function Component() {
  return (
    <Card className="w-[350px]">
      <CardHeader>
        <CardTitle>Card Title</CardTitle>
        <CardDescription>Card description goes here.</CardDescription>
      </CardHeader>
      <CardContent><p className="text-sm">Card content.</p></CardContent>
      <CardFooter><Button size="sm">Action</Button></CardFooter>
    </Card>
  );
}

With Image

Image Placeholder
Card with Image

Supporting text below the title.

Some quick example text to build on the card title and make up the bulk of the card content.

CardWithImage
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card';
import { Button } from '@/components/ui/button';

export default function Component() {
  return (
    <Card className="w-[350px] overflow-hidden">
      <div className="h-48 bg-neutral-100">Image Placeholder</div>
      <CardHeader>
        <CardTitle>Card with Image</CardTitle>
        <CardDescription>Supporting text.</CardDescription>
      </CardHeader>
      <CardContent><p className="text-sm">Content text.</p></CardContent>
      <CardFooter className="gap-2">
        <Button size="sm">Primary</Button>
        <Button size="sm" variant="outlined">Secondary</Button>
      </CardFooter>
    </Card>
  );
}

Simple

A card with only body content, no header or footer.

This is a simple card with only body content. No header or footer needed.

CardSimple
import { Card, CardContent } from '@/components/ui/card';

export default function Component() {
  return (
    <Card className="w-[350px]">
      <CardContent className="pt-6">
        <p className="text-sm">Simple card with only body content.</p>
      </CardContent>
    </Card>
  );
}

Grid Layout

Cards arranged in a responsive grid.

Primary

Card description

Content for the primary card.

Secondary

Card description

Content for the secondary card.

Tertiary

Card description

Content for the tertiary card.

CardGrid
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card';

export default function Component() {
  return (
    <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
      {['Primary', 'Secondary', 'Tertiary'].map((title) => (
        <Card key={title}>
          <CardHeader><CardTitle>{title}</CardTitle><CardDescription>Card description</CardDescription></CardHeader>
          <CardContent><p className="text-sm">Content for the card.</p></CardContent>
        </Card>
      ))}
    </div>
  );
}

API Reference

Card

The root container with border, rounded corners, and shadow.

CardHeader

Top section with vertical spacing for title and description.

CardTitle

Renders an <h3> with appropriate font size and weight.

CardDescription

Muted paragraph text below the title.

CardContent

Main body area with padding.

CardFooter

Bottom section with flex layout for actions.

CardImage

Full-width image with rounded top corners.

On this page