Components / Core
Card
Content container with an optional title, action, media and footer.
import { Card } from "@stylhero/ui";
Example
Code
import { Badge, Button, Card, Grid } from "@stylhero/ui";
function CardExample() {
return (
<Grid minChildWidth={220} gap={4}>
<Card title="Starter build" subtitle="1080p gaming" action={<Badge tone="success">In stock</Badge>}
footer={<Button size="sm">View parts</Button>}>
Ryzen 5, RTX 4060, 32 GB of RAM.
</Card>
<Card variant="outlined" title="Outlined">A border instead of a shadow.</Card>
<Card variant="ghost" title="Ghost">No border or shadow until hover.</Card>
</Grid>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
action |
ReactNode |
- | Top-right of the header, e.g. an IconButton or Menu. |
footer |
ReactNode |
- | Buttons along the bottom (MUI's CardActions). |
media |
ReactNode |
- | Full-bleed image or video on top (MUI's CardMedia). |
subtitle |
ReactNode |
- | Smaller line under the title. |
title |
ReactNode |
- | |
titleAs |
"h2" | "h3" | "h4" | "h5" | "h6" | "p" |
"h3" |
Element for the title, to fit the page's heading outline. Default "h3". |
variant |
"elevated" | "outlined" | "ghost" |
"elevated" |
"outlined": border instead of shadow (MUI's variant="outlined"). "ghost": no surface until hovered, for lists of entries on a page (portfolios, blogs). |
Also takes every <div> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.
Generated from src/components/Card.tsx. Something wrong or missing? Open an issue.