Card

free

Card creates a bounded surface for related content, summaries, and nearby actions.

import { PiQuotes, PiStarFill } from 'react-icons/pi'
import Avatar from '@/components/ui/avatar';
import Card from '@/components/ui/card';

Installation

Add this component with the NateUI CLI.

npx nateui@latest add Card

Examples

Basic

import Card from '@/components/ui/card';

export default function BasicDemo() {
  return (
import { PiDotsThree } from 'react-icons/pi'
import Avatar from '@/components/ui/avatar';
import Button from '@/components/ui/button';
import Card from '@/components/ui/card';

Divided Body

import {
    PiArrowsOut,
    PiDotsThreeVertical,
    PiDownloadSimple,

Borderless

import { PiMapPin } from 'react-icons/pi'
import Card from '@/components/ui/card';
import Tag from '@/components/ui/tag';

Clickable

import Card from '@/components/ui/card';
import { ChevronRight } from '@/components/ui/icons';

export default function ClickableDemo() {

Media

import { ChevronRight } from '@/components/ui/icons';
import Button from '@/components/ui/button';
import Card from '@/components/ui/card';

API

Card exposes a root surface and three compound sections for composing its content.

Card.Body is optional. Put direct children under Card for a simple edge-to-edge surface, and use Card.Body for default padding or an explicit body section.

Card

Card accepts the props below plus native props for the root div.

PropDescriptionTypeDefault
borderedUses the default bordered card surface. Pass false for the shadow card treatment.booleantrue
childrenCard sections or direct children rendered inside the root surface.ReactNode-
classNameClass names applied to the card root.string-
clickableAdds pointer cursor and disables text selection on the card root.booleanfalse
onClickCalled when the card root is clicked.CardClickHandler-
refRef forwarded to the card root.Ref<HTMLDivElement>-
...nativeDivPropsNative props for the root div.NativeCardDivProps-

Card.Header

Card.Header accepts the props below plus native props for its div.

PropDescriptionTypeDefault
borderedAdds the default bottom border and rounded top corners.booleantrue
childrenHeader content rendered inside the section.ReactNode-
classNameClass names applied to the header section.string-
refRef forwarded to the header div.Ref<HTMLDivElement>-
...nativeDivPropsNative props for the header div.NativeCardDivProps-

Card.Body

Card.Body is optional and accepts the props below plus native props for its div. Use it when the card needs default padding or an explicit body section.

PropDescriptionTypeDefault
childrenBody content rendered inside the section.ReactNode-
classNameClass names applied to the body section.string-
refRef forwarded to the body div.Ref<HTMLDivElement>-
...nativeDivPropsNative props for the body div.NativeCardDivProps-

Card.Footer accepts the props below plus native props for its div.

PropDescriptionTypeDefault
borderedAdds the default top border and rounded bottom corners.booleantrue
childrenFooter content rendered inside the section.ReactNode-
classNameClass names applied to the footer section.string-
refRef forwarded to the footer div.Ref<HTMLDivElement>-
...nativeDivPropsNative props for the footer div.NativeCardDivProps-

Header and footer also accept bordered, which defaults to true.

Types

type CardProps = ComponentPropsWithRef<'div'> & {
  clickable?: boolean;
  bordered?: boolean;
  onClick?: CardClickHandler;
};
 
type CardHeaderProps = ComponentPropsWithRef<'div'> & {
  bordered?: boolean;
};
 
type CardBodyProps = ComponentPropsWithRef<'div'>;
 
type CardFooterProps = ComponentPropsWithRef<'div'> & {
  bordered?: boolean;
};
 
type CardClickHandler = (event: MouseEvent<HTMLDivElement>) => void;
type NativeCardDivProps = ComponentPropsWithRef<'div'>;