Skip to Content
Neshel-UI
Components

Card

A surface with header, title, description, content, footer and action parts.

Server-compatible (no "use client")

Purpose

Card groups related content on a surface. Its parts are context-free and composable; use only the ones you need.

Import

import.tsx
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@neshel-ui/components";

Usage

Preview: card-basic
Preview theme

Account overview

Variant “default”.

Active

Three projects, two pending invitations.

Account overview

Variant “outline”.

Active

Three projects, two pending invitations.

Account overview

Variant “muted”.

Active

Three projects, two pending invitations.

card-basic.tsx
import {
  Badge,
  Button,
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@neshel-ui/components";
import { Grid } from "@neshel-ui/layout";
import { Paragraph } from "@neshel-ui/typography";

const variants = ["default", "outline", "muted"] as const;

export default function CardBasic() {
  return (
    <Grid columns={{ base: 1, md: 3 }} space="4">
      {variants.map((variant) => (
        <Card key={variant} variant={variant} as="article" aria-labelledby={`card-${variant}`}>
          <CardHeader>
            <CardTitle id={`card-${variant}`}>Account overview</CardTitle>
            <CardDescription>Variant “{variant}”.</CardDescription>
            <CardAction>
              <Badge variant="success">Active</Badge>
            </CardAction>
          </CardHeader>
          <CardContent>
            <Paragraph size="sm">Three projects, two pending invitations.</Paragraph>
          </CardContent>
          <CardFooter>
            <Button size="sm">Open</Button>
            <Button size="sm" variant="ghost">
              Later
            </Button>
          </CardFooter>
        </Card>
      ))}
    </Grid>
  );
}

API

CardProps

CardProps
PropTypeDefaultDescription
asE——
asChild(required)boolean——
paddingCardPadding——
refRef<HTMLElement>——
variantCardVariant"default"Surface style (default "default").

Also accepts the props of: React DOM attributes.

CardVariant

type CardVariant = "default" | "outline" | "muted"

CardPadding

type CardPadding = "sm" | "md" | "lg"

CardElement

type CardElement = "div" | "section" | "article" | "aside" | "li"

CardTitleProps

CardTitleProps
PropTypeDefaultDescription
asE——
asChild(required)boolean——
refRef<HTMLHeadingElement>——

Also accepts the props of: React DOM attributes.

CardTitleElement

type CardTitleElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "div"

CardDescriptionProps

CardDescriptionProps
PropTypeDefaultDescription
refRef<HTMLParagraphElement>——

Also accepts the props of: React DOM attributes.

CardPartProps

CardPartProps
PropTypeDefaultDescription
refRef<HTMLDivElement>——

Also accepts the props of: React DOM attributes.

PartElementNotes
Carddiv (or as)variant, padding, as, asChild
CardHeaderdivTitle, description and an optional action
CardTitleh3 (or as)h1–h6, p, div; asChild
CardDescriptionpMuted supporting text
CardContentdivMain content
CardFooterdivActions
CardActiondivPlaced at the end of the header

Accessibility

  • Choose CardTitle's level (as) from the page outline.
  • For a card in a list of articles, use as="article" and aria-labelledby pointing to the title.
  • Cards are not interactive: put buttons or links inside; never wrap a whole card in a link or button.

Common mistakes

  • Making the entire card clickable with onClick: keyboard and screen-reader users cannot discover it.
  • Several CardTitles with the default h3 breaking the heading outline.
Edit on GitHub

On this page