Playground

Card

A bordered group for one thing you can pick up or open.

  • Built on radix-ui/Slot
  • 6 parts, named exports
  • Plain divs and a heading; no roles added.
  • With asChild on a link or button the whole card is one keyboard-focusable control.
  • Styles in one file: 06-boxes.css

Import

import '@monoline/css';
import {Card} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add card

It needs radix-ui; install it if your project does not have it:

npm install radix-ui

Usage

import {Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle} from '@monoline/react';

<div style={{maxWidth: 360}}>
  <Card>
    <CardHeader>
      <CardTitle>Ship the pricing page</CardTitle>
      <CardDescription>Today, 14:20 · 3 files</CardDescription>
    </CardHeader>
    <CardContent>
      <p>Rewrote the headline and the plan table.</p>
    </CardContent>
    <CardFooter>
      <Button variant="solid" size="sm">Open</Button>
      <Button variant="line" size="sm">Share</Button>
    </CardFooter>
  </Card>
</div>

Anatomy

Import the parts you need and nest them like this.

import {Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter} from '@monoline/react';

<Card>
  <CardHeader />
  <CardTitle />
  <CardDescription />
  <CardContent />
  <CardFooter />
</Card>

Examples

Basic

asChild makes the whole card one link.

Props

CardProps

PropTypeDefaultDescription
interactiveboolean–Adds a hover outline. Use with `asChild` on a link or button so the whole card is one control.
asChildboolean–Render the child element (a link, an `article`) with the card styles instead of a `div`.

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.banner06-boxes.css
.banner-accent06-boxes.css
.banner-danger06-boxes.css
.banner-warning06-boxes.css
.card06-boxes.css
.card-hover06-boxes.css
.cardcard.css
.card-contentcard.css
.card-descriptioncard.css
.card-footercard.css
.card-headercard.css
.card-titlecard.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.banner {
  border-color: var(--accent);
}

Try the props

Change a prop and the component above updates; the code below is what you would write. To edit the code itself, use the Playground.

Team plan

Shared projects and roles.

Up to 20 people. Billed monthly.
example.tsx
<Card>
  <CardHeader>
    <CardTitle>Team plan</CardTitle>
    <CardDescription>Shared projects and roles.</CardDescription>
  </CardHeader>
  <CardContent>Up to 20 people. Billed monthly.</CardContent>
  <CardFooter>
    <Button variant="solid">Choose plan</Button>
  </CardFooter>
</Card>

Accessibility

  • Plain divs and a heading; no roles added.
  • With asChild on a link or button the whole card is one keyboard-focusable control.