Card
A bordered group for one thing you can pick up or open.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsstable
- 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
Props
CardProps
| Prop | Type | Default | Description |
|---|---|---|---|
interactive | boolean | – | Adds a hover outline. Use with `asChild` on a link or button so the whole card is one control. |
asChild | boolean | – | 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
| Class | Stylesheet |
|---|---|
.banner | 06-boxes.css |
.banner-accent | 06-boxes.css |
.banner-danger | 06-boxes.css |
.banner-warning | 06-boxes.css |
.card | 06-boxes.css |
.card-hover | 06-boxes.css |
.card | card.css |
.card-content | card.css |
.card-description | card.css |
.card-footer | card.css |
.card-header | card.css |
.card-title | card.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.
.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.
<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.