Components / Display

Card05

A box for related content: a title, a body, actions and a footer. Sticker can tape it to the page, Retro turns it into a window, Comic into a panel with a caption box, Arcade into a score screen.

Card · PlaygroundLive

Weekly report

Signups are up 12% since the new onboarding shipped.
tilt
JSX
<Card title="Weekly report">
  Signups are up 12% since the new onboarding shipped.
</Card>

Usage

TSX
import { Card } from "plonk-ui";

export function Report() {
  return (
    <Card title="Weekly report">
      Signups are up 12% since the new onboarding shipped.
    </Card>
  );
}

Card is a <section>. Every part is optional, and only the parts you pass are rendered, so a card can be just a body or just a title.

Anatomy

title and description head the card, actions sit to the right of the title, children is the body and footer holds the buttons at the bottom.

Card · AnatomyLive

Spring launch

On track

Landing page, emails and the press kit.

Copy is final. Illustrations land on Friday, then we hand everything to the dev team.
TSX
import { Badge, Button, Card } from "plonk-ui";

export default function Anatomy() {
  return (
    <Card
      className="w-full max-w-sm"
      title="Spring launch"
      description="Landing page, emails and the press kit."
      actions={<Badge variant="success">On track</Badge>}
      footer={
        <>
          <Button size="sm">Open board</Button>
          <Button size="sm" variant="ghost">
            Share
          </Button>
        </>
      }
    >
      Copy is final. Illustrations land on Friday, then we hand everything to
      the dev team.
    </Card>
  );
}

Closable

Pass onClose to show a close box. The card doesn't hide itself; you decide what closing means. Give the box a specific name with closeLabel.

Card · ClosableLive

Tip

Press ⌘K anywhere to jump to a page.
TSX
import { useState } from "react";
import { Button, Card } from "plonk-ui";

export default function Closable() {
  const [open, setOpen] = useState(true);

  if (!open) {
    return (
      <Button variant="neutral" onPress={() => setOpen(true)}>
        Bring the tip back
      </Button>
    );
  }

  return (
    <Card
      className="w-full max-w-xs"
      title="Tip"
      onClose={() => setOpen(false)}
      closeLabel="Dismiss tip"
    >
      Press ⌘K anywhere to jump to a page.
    </Card>
  );
}

Tilt

tilt sticks the card on at a slight angle, to the left or the right. The angle is the personality's --plonk-tilt: 1.5° in Sticker, 0.8° in Comic, and none in Retro and Arcade, which stay straight.

Card · TiltLive

To do

Pick fonts

Done

Choose a name
TSX
import { Card } from "plonk-ui";

export default function Tilt() {
  return (
    <div className="flex flex-wrap justify-center gap-6">
      <Card tilt="left" title="To do" className="w-44">
        Pick fonts
      </Card>
      <Card tilt="right" title="Done" className="w-44">
        Choose a name
      </Card>
    </div>
  );
}

Tape

Cards have no tape by default. Add it with tape, and each personality draws its own: paper tape in Sticker, a dithered pixel strip at the top right in Retro, a blue halftone strip in Comic, and a blinking neon "1UP" plate in Arcade.

TSX
<Card tape title="Pinned note">
  Same prop, four kinds of tape.
</Card>;
01Sticker"sticker"Squash, stretch, spring back

Pinned note

Same prop, four kinds of tape.
02Retro"retro"Stepped, instant, framed

Pinned note

Same prop, four kinds of tape.
03Comic"comic"Fast, overshooting, loud

Pinned note

Same prop, four kinds of tape.
04Arcade"arcade"Pixel steps, neon, points

Pinned note

Same prop, four kinds of tape.

The provider's tape setting turns tape off for toasts and the data table, but never adds it to cards: a card only has tape when you ask for it. See Personalities for the global switch.

Personalities

Sticker is a sheet of paper with a hard shadow. Retro wraps the card in a window with a striped title bar, and the close box moves to the left like on an old Mac. Comic prints a halftone corner and puts the title in a yellow caption box. Arcade lights the title up like a high score.

Accessibility

  • A card with a title is a region named by its title, so screen reader users can find it in the landmarks list. Without a title it's a plain section.
  • The title is an <h3> by default. Set headingLevel so it follows the page's outline: a card under an <h2> section keeps 3, a card that starts its own section can use 2.
  • The close box is a real button with an accessible name, "Close" by default.
  • Tape, halftone and title bar stripes are decoration and stay silent.

API

All other <section> props are passed through.

PropTypeDefaultDescription
titleReactNode—Heading, used to name the card's region. In Retro it sits in the window's title bar.
descriptionReactNode—Muted line under the title.
actionsReactNode—Content on the right of the header, like a badge, a button or a menu.
footerReactNode—Bottom row, usually buttons. Wraps on narrow screens.
onClose() => void—Shows a close box and calls this when it's pressed. Retro puts it at the left of the title bar.
closeLabelstring"Close"Accessible name of the close box.
tapebooleanfalseSticks decorative tape on top, drawn differently by each personality.
tilt"left" | "right"—Sticks the card on at the personality's tilt angle. Retro and Arcade stay straight.
headingLevel2 | 3 | 4 | 5 | 63Heading level of the title, so it fits your page's outline.