Card

Displays a card with header, content, and footer.

Notifications

You have 3 unread messages.

Push Notifications

Send notifications to device.

Your call has been confirmed.

1 hour ago

You have a new message!

1 hour ago

Your subscription is expiring soon!

2 hours ago

Installation

Copy and paste the following code into your project.

import { tv } from "tailwind-variants";
 
export const CardStyles = {
  Root: tv({
    base: ["rounded-xl border bg-card text-card-foreground shadow"],
  }),
  Header: tv({
    base: ["flex flex-col space-y-1.5 p-6"],
  }),
  Title: tv({
    base: ["font-semibold leading-none tracking-tight"],
  }),
  Description: tv({
    base: ["text-muted-foreground text-sm"],
  }),
  Content: tv({
    base: ["p-6 pt-0"],
  }),
  Footer: tv({
    base: ["flex items-center p-6 pt-0"],
  }),
};
 
export type CardRootProps = React.ComponentProps<"div">;
 
export function CardRoot({ className, ...props }: CardRootProps) {
  return <div {...props} className={CardStyles.Root({ className })} />;
}
 
export type CardHeaderProps = React.ComponentProps<"header">;
 
export function CardHeader({ className, ...props }: CardHeaderProps) {
  return <header {...props} className={CardStyles.Header({ className })} />;
}
 
export type CardTitleProps = React.ComponentProps<"h3">;
 
export function CardTitle({ className, ...props }: CardTitleProps) {
  return <h3 {...props} className={CardStyles.Title({ className })} />;
}
 
export type CardDescriptionProps = React.ComponentProps<"p">;
 
export function CardDescription({ className, ...props }: CardDescriptionProps) {
  return <p {...props} className={CardStyles.Description({ className })} />;
}
 
export type CardContentProps = React.ComponentProps<"div">;
 
export function CardContent({ className, ...props }: CardContentProps) {
  return <div {...props} className={CardStyles.Content({ className })} />;
}
 
export type CardFooterProps = React.ComponentProps<"footer">;
 
export function CardFooter({ className, ...props }: CardFooterProps) {
  return <footer {...props} className={CardStyles.Footer({ className })} />;
}
 
export const Card = Object.assign(
  {},
  {
    Root: CardRoot,
    Header: CardHeader,
    Title: CardTitle,
    Description: CardDescription,
    Content: CardContent,
    Footer: CardFooter,
  }
);

Update the import paths to match your project setup.

Usage

Single import

import { Card } from "~/components/ui/card";
<Card.Root>
  <Card.Header>
    <Card.Title>Card Title</Card.Title>
    <Card.Description>Card Description</Card.Description>
  </Card.Header>
  <Card.Content>
    <p>Card Content</p>
  </Card.Content>
  <Card.Footer>
    <p>Card Footer</p>
  </Card.Footer>
</Card.Root>

Multiple imports

import {
  CardRoot,
  CardHeader,
  CardTitle,
  CardDescription,
  CardContent,
  CardFooter,
} from "~/components/ui/card";
<CardRoot>
  <CardHeader>
    <CardTitle>Card Title</CardTitle>
    <CardDescription>Card Description</CardDescription>
  </CardHeader>
  <CardContent>
    <p>Card Content</p>
  </CardContent>
  <CardFooter>
    <p>Card Footer</p>
  </CardFooter>
</CardRoot>

Examples

Notifications

You have 3 unread messages.

Push Notifications

Send notifications to device.

Your call has been confirmed.

1 hour ago

You have a new message!

1 hour ago

Your subscription is expiring soon!

2 hours ago