React
Description
Section titled “Description”The Card is a thin wrapper that renders the tng-card element and nothing else: the content, layouts, components and utilities that make up each card in Figma are provided by the caller as children. Every opt-in feature (surface, border, backdrop, scrim, contrast, responsive padding) is a class added through className; see the CSS tab for what each one does.
The wrapper can render as one of three elements:
div(default): a plain container.article: a self-contained piece of content, such as a card in a carousel or a list.anchor: the whole card is one destination. Passhreflike on any anchor element.
Component
Section titled “Component”Properties
Section titled “Properties”CardProperties extends <React.HTMLAttributes<HTMLDivElement>>, <React.HTMLAttributes<HTMLElement>> or <React.AnchorHTMLAttributes<HTMLAnchorElement>> depending on the as prop, which means it includes all standard HTML attributes (including children and ref) that can be applied to that element. href, target and rel are therefore only available with as="anchor".
| Prop | Type | Description | Optional |
|---|---|---|---|
as |
'div' | 'anchor' | 'article' |
The element to render, 'div' by default |
✅ |
className |
ClassValue |
Additional class names can be added (tng-card is added by default) |
✅ |
Classes
Section titled “Classes”These classes can be added through className.
| Class | Description |
|---|---|
has-surface |
Paints the card’s own background: --tng-cards-rested-background-color, or --tng-color-surface-contrast-subtle on a contrast card |
has-border |
Draws a 1px border: --tng-cards-border-color, or --tng-color-border-contrast-muted on a contrast card. Use the border utilities for any other border |
has-backdrop |
Dims the media that covers the card evenly and switches the text to the contrast colour. Add is-contrast when the card holds components, so they switch too |
has-scrim |
Lays a dark gradient over the media that covers the card, darkest at the top and bottom edges, and switches the text to the contrast colour |
is-contrast |
Switches the card and everything inside it (text, surface, border and components) to the contrast scheme |
is-responsive-padding |
The card has 16px of padding by default. With this class the inline padding becomes 24px, but only from 1024px upwards; below that it stays 16px |
tng-card-fullbleed |
Set on a direct child: it bleeds through the inline padding to the card’s edge, and through the block padding when it is the first or last child |
Layout and spacing utilities (gap-*, p-*, align-items-*, justify-content-*, text-*) and tng-frame with its aspect ratios (is-16-9, is-21-9, is-9-16) are added the same way.
A direct-child <img>, <picture>, <video> or .tng-card-media covers the whole card, behind the content. Combine it with has-backdrop or has-scrim to keep the text readable. To place media inside the padding instead, wrap it in a tng-frame; add tng-card-fullbleed to let it bleed to the card’s edge.
Examples
Section titled “Examples”Simple card
Section titled “Simple card”A div card with media behind the content (has-backdrop), a border, and everything switched to the contrast scheme (is-contrast). gap-3xl widens the gap between the children.
import { Card, Link } from '@tmedxp/react-components';
const SimpleCardExample = () => { return ( <Card className="has-backdrop has-border is-contrast gap-3xl"> <img src="/assets/toyota-mania.webp" alt="" /> <h3 className="tng-text-title">Toyota Mania</h3> <p className="tng-text-body">Every model, every era, one weekend.</p> <Link href="#" text="Get tickets" isNeutral trailingIcon="arrow-right" opensInNewWindowLabel="Opens in a new window" /> </Card> );};
export { SimpleCardExample };Feature carousel card
Section titled “Feature carousel card”Rendered as an article. A surface, a border and responsive padding (is-responsive-padding) frame the card, and the media bleeds to the card’s edge (tng-card-fullbleed). gap-3xl and pbe-3xl set the spacing between the children and below the last one.
import { Card, Icon, IconButton, MainButton } from '@tmedxp/react-components';
const FeatureCarouselCardExample = () => { return ( <Card as="article" className="has-surface has-border is-responsive-padding gap-3xl pbe-3xl" > <div className="tng-frame tng-card-fullbleed"> <img src="/assets/toyota-mania.webp" alt="" /> <IconButton iconName="player" size="md" isFilled className="on-contrast align-self-center justify-self-center" aria-label="Play video" /> <span className="tng-tag align-self-end justify-self-end m-3xl"> Topic 1 </span> </div> <span className="tng-label align-self-end"> <Icon name="time" /> <span>2 min</span> </span> <div className="tng-stack gap-xl"> <h3 className="tng-text-title is-8">Toyota Mania</h3> <p className="tng-text-body">Every model, every era, one weekend.</p> </div> <MainButton as="link" href="#" text="Get tickets" /> <MainButton as="link" href="#" variant="secondary" text="See the programme" /> </Card> );};
export { FeatureCarouselCardExample };Smart block card
Section titled “Smart block card”Rendered as an anchor, so the whole card is one destination. tng-frame is-16-9 makes the card a 16:9 frame that the image fills, has-scrim darkens it, and the utilities replace the default padding and gap and centre the text at the bottom.
import { Card } from '@tmedxp/react-components';
const SmartBlockCardExample = () => { return ( <Card as="anchor" href="#" className="has-scrim tng-frame is-16-9 p-4xl gap-none justify-content-end align-items-center text-center" > <img src="/assets/toyota-mania.webp" alt="" /> <span className="tng-text-title is-10 tng-overflow-ellipsis"> New cars </span> <span className="tng-text-body is-emphasis"> Find the Toyota that fits your life. </span> </Card> );};
export { SmartBlockCardExample };Media with a scrim
Section titled “Media with a scrim”A div card framed at 16:9 with a gradient over the image (has-scrim), so the title stays readable at the bottom (justify-content-end).
import { Card } from '@tmedxp/react-components';
const ScrimCardExample = () => { return ( <Card className="has-scrim tng-frame is-16-9 justify-content-end"> <img src="/assets/toyota-mania.webp" alt="" /> <h3 className="tng-text-title">Toyota Mania</h3> </Card> );};
export { ScrimCardExample };Contrast card with a button
Section titled “Contrast card with a button”A card with a surface and a border on the contrast scheme (is-contrast): the button inside switches with it.
import { Card, MainButton } from '@tmedxp/react-components';
const ContrastCardExample = () => { return ( <Card className="has-surface has-border is-contrast"> <h3 className="tng-text-title">Toyota Mania</h3> <MainButton as="link" href="#" variant="secondary" text="Get tickets" /> </Card> );};
export { ContrastCardExample };