Skip to main content

Card

A container used to display content in a box, resembling a physical card. Composed of several sub-components.

When to use

A Card groups related content in a raised box, with an optional header and footer.

  • Prefer Well when the content is secondary and sits inset in the page, such as a code sample, a note, or a read-only summary.
  • Prefer Separator when adjacent content needs a divider and no box.
  • Prefer MediaObject when an icon or a figure sits beside a block of text, with no border.

Laborum in aute officia adipisicing elit velit.

Card Title Here

Laborum in aute officia adipisicing elit velit.

Card footer

Card Title Here

Laborum in aute officia adipisicing elit velit.

Laborum in aute officia adipisicing elit velit.

Card footer

import { Card } from "@ngrok/mantle/card"; <Card.Root>	<Card.Body>		<p>Laborum in aute officia adipisicing elit velit.</p>	</Card.Body></Card.Root> <Card.Root className="shadow-lg">	<Card.Header>		<Card.Title>Card Title Here</Card.Title>	</Card.Header>	<Card.Body>		<p>Laborum in aute officia adipisicing elit velit.</p>	</Card.Body>	<Card.Footer>		<p>Card footer</p>	</Card.Footer></Card.Root> <Card.Root>	<Card.Header>		<Card.Title>Card Title Here</Card.Title>	</Card.Header>	<Card.Body>		<p>Laborum in aute officia adipisicing elit velit.</p>	</Card.Body></Card.Root> <Card.Root>	<Card.Body>		<p>Laborum in aute officia adipisicing elit velit.</p>	</Card.Body>	<Card.Footer>		<p>Card footer</p>	</Card.Footer></Card.Root>

Composition

Compose the parts of a Card together to build your own:

Card.Root├── Card.Header│   └── Card.Title├── Card.Body└── Card.Footer

Polymorphism

Every Card part accepts an asChild prop. When true, the part renders its single child instead of its default element, forwarding all class names, data-* attributes, and the ref onto that child. Reach for this when a card part should also be a more semantic element: for example, rendering Card.Title as an h2 to fit the surrounding document outline.

Card Title as an h2

Laborum in aute officia adipisicing elit velit.

import { Card } from "@ngrok/mantle/card"; <Card.Root>	<Card.Header>		<Card.Title asChild>			<h2>Card Title as an h2</h2>		</Card.Title>	</Card.Header>	<Card.Body>		<p>Laborum in aute officia adipisicing elit velit.</p>	</Card.Body></Card.Root>;

API Reference

Card.Root

A container that displays content in a box resembling a physical card. The root component of all Card sub-components.

All props from div, plus:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card styling onto alternative element types or your own React components.

Card.Body

The main content of a card. Usually composed as a direct child of Card.Root.

All props from div, plus:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Body styling onto alternative element types or your own React components.

Card.Footer

The band below Card.Body. Unless it is the first child, it draws a top border dividing the two. Pass it as a direct child of Card.Root.

All props from div, plus:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Footer styling onto alternative element types or your own React components.

Card.Header

The band above Card.Body that holds Card.Title. Pass it as a direct child of Card.Root.

All props from div, plus:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Header styling onto alternative element types or your own React components.

Card.Title

The heading inside Card.Header. Renders an h3 by default — pass asChild to fit the surrounding document outline. Keep it a heading element (h1-h6) for accessibility.

All props from h1-h6, plus:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Title styling onto alternative element types or your own React components.