Skip to content
TopClass UI

Card

A surface for content that belongs together, with a larger radius than a control so it never reads as a button.

server - 0 KB

Card

server - 0 KB

A surface for content that belongs together, with a larger radius than a control so it never reads as a button.

Install

Storage

You have used 18 GB of the 50 GB in your plan.

The code

card.tsx
import { CardBody, CardHeader, CardRoot } from 'topclassui/card'

/** The first drawing: a title and a line of text, with nothing to press. */
export default function Demo() {
  return (
    <div className="max-w-xs">
      <CardRoot>
        <CardHeader>
          <h2>Storage</h2>
        </CardHeader>
        <CardBody>You have used 18 GB of the 50 GB in your plan.</CardBody>
      </CardRoot>
    </div>
  )
}

Card sets the type of its title and leaves the heading level to you: put the h2 or h3 inside CardHeader.

Every state

3 states

Storage

You have used 18 GB of the 50 GB in your plan.
Idle

Version 0.4

Card is now CardRoot. Find and replace; nothing else changed.
With actions
Loading

Import from the package

topclassui/card
import { CardRoot, CardHeader, CardBody, CardFooter, CardSkeleton } from 'topclassui/card'

Install once:npm i topclassui@beta zod

Examples

  • Every part is a flat export: CardRoot, CardHeader, CardBody, CardFooter and CardSkeleton. There is no Card.
  • A card is not interactive itself; what the user can do goes in CardFooter as a Button, in a row that wraps when the card is narrow.
  • CardBody is a block, so space several paragraphs yourself, for example with space-y-2.
  • Card takes the width of its container: in a grid, each card fills its cell and the height of its row.
  • CardSkeleton holds the full width at 5:2 while data loads; pass the real height in className.
basic

Storage

You have used 18 GB of the 50 GB in your plan.
with-actions

Version 0.4

Card is now CardRoot. Find and replace; nothing else changed.
report

Monthly report

Revenue rose 12% against April, driven by renewals.
paragraphs

Before you migrate

Export your projects first. The archive keeps every file and its history.

Invitations that are still pending do not move, so send them again afterwards.

grid

Starter

One project and 5 GB of storage.

Team

Ten projects, 50 GB of storage and a shared library for the whole team.

Business

Unlimited projects and single sign-on.
skeleton

Storage

You have used 18 GB of the 50 GB in your plan.
In Arabic, right to left

التقرير الشهري

ارتفعت الإيرادات 12% مقارنة بشهر أبريل، بفضل التجديدات.

Props

CardRoot

The props of CardRoot
PropTypeDefaultLimitsDescription
childrenReactNode--The parts, in order: CardHeader, CardBody and CardFooter. Each one is optional.

CardHeader

The props of CardHeader
PropTypeDefaultLimitsDescription
childrenReactNode--The title, in the heading element the page outline needs.

CardBody

The props of CardBody
PropTypeDefaultLimitsDescription
childrenReactNode--The text. Several paragraphs are spaced by the caller.

CardFooter

The props of CardFooter
PropTypeDefaultLimitsDescription
childrenReactNode--The actions, in a row that wraps when the card is narrow.

CardSkeleton

No props of its own: it takes the attributes of the element it renders.

Keyboard and accessibility

Nothing to operate: it is not interactive on its own.

  • Card renders plain div elements with no role: what it holds gives it meaning.
  • Pick the heading level the page outline needs; CardHeader styles whatever heading you put in it.
  • CardSkeleton is hidden from assistive technology, so mark the loading region itself, for example with aria-busy.

Right to left

The footer's buttons start at the inline start, so in Arabic the first one sits on the right; text aligns to the start.

Server and client

Renders on the server and ships no JavaScript.

Files: index.tsx.

On the chip: server - 0 KB.