Card
⋯
Card renders a surface with a 1px border, 16px radius, 12px padding, and 12px gap. The background
is neutral by default or gray with variant="gray". Compose headings, text, media, and
controls as children.
import { Card } from "@nesra/ui/card";
export function CampaignCard() { return ( <Card> <h3>Campaign overview</h3> <p>Performance this week</p> </Card> );}Card is also exported from @nesra/ui.
Examples
Section titled “Examples”Basic card
Section titled “Basic card”import { Card } from "@nesra/ui/card";
export function CardBasicExample() { return ( <Card className="w-full max-w-sm"> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline">Campaign overview</h3> <p className="type-nesra-body-xsmall-regular text-nesra-text-support"> Performance this week </p> </Card> );}Variants
Section titled “Variants”neutral is the default card background, white in Light and gray-900 in Dark. gray changes only the background.
import { Card } from "@nesra/ui/card";
export function CardVariantsExample() { return ( <div className="grid w-full gap-nesra-padding-xl sm:grid-cols-2"> <Card> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline">Neutral</h3> <p className="type-nesra-body-xsmall-regular text-nesra-text-support"> Neutral card background </p> </Card> <Card variant="gray"> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline">Gray</h3> <p className="type-nesra-body-xsmall-regular text-nesra-text-support"> Gray card background </p> </Card> </div> );}Simple surface
Section titled “Simple surface”Card can wrap content without a prescribed header.
import { Card } from "@nesra/ui/card";
export function CardSurfaceExample() { return ( <Card className="w-full max-w-sm"> <p className="type-nesra-body-small-regular text-nesra-text-body"> Your report is ready to review. </p> </Card> );}Gray surface and inset panel
Section titled “Gray surface and inset panel”The AdX Creative Card in Figma uses the default neutral surface and 12px padding. KPI Summary Card uses the gray variant with 4px padding. The example composes an inset panel using semantic tokens. It does not reproduce the KPI icon, checkbox, or trend badge.
import { Card } from "@nesra/ui/card";
export function CardGrayExample() { return ( <Card className="w-full max-w-[275px] gap-0 p-nesra-padding-xs" variant="gray"> <header className="px-nesra-padding-md py-nesra-padding-xl"> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline">Revenue</h3> <p className="type-nesra-body-xsmall-regular text-nesra-text-support">Last seven days</p> </header> <div className="rounded-nesra-xl border border-nesra-stroke-divider bg-nesra-surface-card-bg-neutral px-nesra-padding-md py-nesra-padding-2xl"> <p className="type-nesra-heading-h6 text-nesra-text-headline">Rp 999.000.000</p> <p className="type-nesra-body-xsmall-regular text-nesra-text-support"> Trending up from last week </p> </div> </Card> );}Sections
Section titled “Sections”Native header, dl, and footer elements organize content without adding Card subcomponents.
import { Card } from "@nesra/ui/card";
export function CardSectionsExample() { return ( <Card className="w-full max-w-sm"> <header> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline"> Campaign summary </h3> <p className="type-nesra-body-xsmall-regular text-nesra-text-support">This month</p> </header> <dl className="grid gap-nesra-padding-md border-t border-nesra-stroke-divider pt-nesra-padding-xl"> <div className="flex justify-between gap-nesra-padding-xl"> <dt className="type-nesra-body-xsmall-regular text-nesra-text-support">Spend</dt> <dd className="type-nesra-body-xsmall-medium text-nesra-text-body">Rp 2.104.677</dd> </div> <div className="flex justify-between gap-nesra-padding-xl"> <dt className="type-nesra-body-xsmall-regular text-nesra-text-support">Conversions</dt> <dd className="type-nesra-body-xsmall-medium text-nesra-text-body">148</dd> </div> </dl> <footer className="border-t border-nesra-stroke-divider pt-nesra-padding-xl type-nesra-body-xsmall-regular text-nesra-text-support"> Updated today </footer> </Card> );}Actions
Section titled “Actions”Button owns the disclosure interaction. Card remains a static container.
import { Button } from "@nesra/ui/button";import { Card } from "@nesra/ui/card";import { useId, useState } from "react";
export function CardActionsExample() { const detailsId = useId(); const [showDetails, setShowDetails] = useState(false);
return ( <Card className="w-full max-w-sm"> <div className="flex items-start justify-between gap-nesra-padding-xl"> <div> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline">Weekly report</h3> <p className="type-nesra-body-xsmall-regular text-nesra-text-support"> Updated this morning </p> </div> <Button aria-controls={detailsId} aria-expanded={showDetails} onClick={() => setShowDetails((value) => !value)} size="sm" variant="outline" > {showDetails ? "Hide" : "Show"} </Button> </div> <p className="type-nesra-body-small-regular text-nesra-text-body" hidden={!showDetails} id={detailsId} > The report includes campaign spend and conversion totals. </p> </Card> );}Multiple cards
Section titled “Multiple cards”import { Card } from "@nesra/ui/card";
const reports = [ { title: "Revenue", value: "Rp 999.000.000" }, { title: "Conversions", value: "1,248" }, { title: "Active campaigns", value: "12" },];
export function CardMultipleExample() { return ( <div className="grid w-full gap-nesra-padding-xl sm:grid-cols-3"> {reports.map((report) => ( <Card key={report.title}> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline"> {report.title} </h3> <p className="type-nesra-heading-h6 text-nesra-text-body">{report.value}</p> </Card> ))} </div> );}Filtered content
Section titled “Filtered content”Input and application state filter the list. Card only groups the controls and results.
import { Card } from "@nesra/ui/card";import { Input } from "@nesra/ui/input";import { useState } from "react";
const reportNames = ["Campaign overview", "Creative performance", "Weekly revenue"];
export function CardFilterExample() { const [query, setQuery] = useState(""); const matches = reportNames.filter((name) => name.toLowerCase().includes(query.toLowerCase()));
return ( <Card className="w-full max-w-md"> <h3 className="type-nesra-body-small-semibold text-nesra-text-headline">Reports</h3> <Input aria-label="Filter reports" onChange={(event) => setQuery(event.currentTarget.value)} placeholder="Filter reports" type="search" value={query} /> <ul className="grid gap-nesra-padding-md type-nesra-body-small-regular text-nesra-text-body"> {matches.map((name) => ( <li key={name}>{name}</li> ))} </ul> <output className="type-nesra-body-xsmall-regular text-nesra-text-support"> {matches.length} of {reportNames.length} reports </output> </Card> );}The Figma card set does not define a generic size or interaction variant. Thumbnail, metric, checkbox, trend, and tooltip behavior belong to the consuming composition.
Light and Dark
Section titled “Light and Dark”Card follows the page theme through .dark or data-theme="dark". The border uses
Stroke/stroke-border (--nesra-stroke-border). The neutral background uses
Surface/card-bg-neutral (white in Light, gray-900 in Dark), and gray uses
Surface/card-bg-gray (gray-50 in Light, gray-800 in Dark). Text inside a card should use the text
roles, such as text-nesra-text-body and text-nesra-text-support, so it switches with the card.
Accessibility
Section titled “Accessibility”Card renders a div without a role or tab stop. Use native headings at the correct level for the
page. Give controls and media inside the card their own accessible names and behavior. In the filter
example, Input has an accessible name and output announces the result count.
API reference
Section titled “API reference”Card accepts native div props, forwards its ref, and exposes data-slot="card" and
data-variant. Use className to adjust spacing or override the background. It has no interaction
state.
| Prop | Type | Default | Effect |
|---|---|---|---|
variant |
"neutral" | "gray" |
"neutral" |
Sets the card background role. |
The visual values come from the color roles, layout scale, and shape and elevation tokens.