Installation
Section titled “Installation”- Package
@bigbang/ui- Import
import { Card } from '@bigbang/ui';- Source
- Card.tsx
- Storybook
- Card · Playground
Card is in the @bigbang/ui package. Installation and style files are the same as for Button; see the Button code tab.
import { Card } from '@bigbang/ui';
<Card> <Card.Header> <Card.Title>Card title</Card.Title> <Card.Description>Card description goes here.</Card.Description> </Card.Header> <Card.Body>Card content</Card.Body></Card>;The part prop types are exported too: CardHeaderProps, CardTitleProps, CardDescriptionProps, CardActionsProps, CardBodyProps, CardFooterProps, CardLinkProps.
variant- Description
- How the card separates from the page:
outlinedhas a 1 px border,elevateda shadow,filleda tinted surface. - Type
'outlined' | 'elevated' | 'filled'- Default
'outlined'
padding- Description
- Inner padding and the gap between parts: 12, 16 or 24 px. Use
lgfor a single card on a page,mdin grids andsmin dense lists and side panels. - Type
'sm' | 'md' | 'lg'- Default
'md'
interactive- Description
- The whole card opens one destination: it lifts on hover and shows the focus ring of its
Card.Link. Put exactly oneCard.Linkin the title. - Type
boolean- Default
false
render- Description
- Renders the root as another element, such as
<article />or<li />. A card with aCard.Titleis a<section>by default. - Type
ReactElement | ComponentRenderFn<HTMLProps, {}>
className- Description
- For layout only: margins, width and grid placement. Do not use it to change colour or padding.
- Type
string
children- Description
- The card parts:
Card.Header,Card.BodyandCard.Footer, or any content. - Type
ReactNode
Native attributes (id, aria-*) pass through to the root element.
| Part | Element | Props |
|---|---|---|
Card.Header |
<div> |
Native attributes. With Card.Actions inside it becomes a two-column grid. |
Card.Title |
<h2>-<h6> |
level (default 3). Names the card region; the card sets its id. |
Card.Description |
<p> |
Native attributes. |
Card.Actions |
<div> |
Native attributes. Sits above the link (z-1). |
Card.Body |
<div> |
Native attributes. |
Card.Footer |
<div> |
Native attributes. Sits above the link (z-1). |
Card.Link |
<a> |
Native link attributes and render (for a router link). |
Data attributes
Section titled “Data attributes”data-component="card",data-variant,data-interactive: on the root.data-part:header,title,description,actions,body,footer,link.
Router link
Section titled “Router link”import { Card } from '@bigbang/ui';import { Link } from 'react-router';
<Card interactive> <Card.Title> <Card.Link render={<Link to="/records/42" />}>Card title</Card.Link> </Card.Title></Card>;Cards in a list
Section titled “Cards in a list”<ul className="grid gap-xl md:grid-cols-3"> {items.map((item) => ( <Card key={item.id} render={<li />}> <Card.Title>{item.title}</Card.Title> </Card> ))}</ul>