Card

Use the card component to display information in a compact way and link to other internal pages.

Ready to use
Reviewed for accessibility
import {Avatar, Box, Card, Grid, Token} from '@primer/react-brand'

Examples

Default

The default card displays a heading and description. The link text defaults to Learn more, but can be customized using the ctaText prop.

Loading

Minimal

The minimal card variant applies alternative presentation to the default card.

Loading

CTA text

The call to action text defaults to Learn more and can be customized using the ctaText property.

Loading

Use ctaVariant="none" when the card should remain fully clickable without visible CTA text or arrow.

Loading

Arrow CTA

Use ctaVariant="arrow" when the card should present an icon-only call to action instead of the default text-plus-arrow treatment.

Loading

Border

A border can be provided using the hasBorder prop. This will render a border around the Card component giving further separation between the foreground and background. Especially when there is no shadow present on the background.

Loading

Icon

You can add an icon to enhance the visual context. We recommend using an Octicon. The Icon can be customized using the color prop and used with or without a background color by using the hasBackground prop. Use Card.Tokens to display one or more Token components below the description. The heading and description still render before the tokens in the DOM, so the reading order stays aligned with the visual order.

Loading

Label

Use Card.Label to display a short label above the heading. It renders a Token by default. Use variant="accent-text" for eyebrow-style copy.

Loading
Loading

Image

Use the Image component to add an image to the Card. The Image component is optional and provides a visual context to the Card.

Loading

Tokens

Use Card.Tokens to display more than one Token.

Loading

Component props

Card Required

nametypedefaultrequireddescription
align'start'
'center'
'start'falseAligns the card content
backgroundColor'default', 'subtle', 'none''default'falseOptional background color override for the card
ctaTextstringLearn morefalseLabel of the link at the bottom of the card
ctaVariant'text', 'arrow', 'none''text'falsePresentation of the call-to-action area
disableAnimationbooleanfalsefalseA flag to disable the default hover animation effect of the card
fullWidthbooleanfalsefalseA flag to optionally fill the width of the parent container
hasBorderbooleanfalsefalseA flag used to provide a border to the card
hrefstringtrueURL to the card content
leadingVisualReactElementfalseLogo or brand mark shown above the card content
variant'default', 'minimal''default'falseThe variant of the card

Card.Image

Forwards all the props from the Image component, including src, alt, and aspectRatio.

Card.Icon

nametypedefaultrequireddescription
iconReact.NodetrueOcticon
color'default', 'subtle', 'accent', 'success', 'attention', 'severe', 'danger', 'open', 'closed', 'done', 'sponsors', 'blue', 'green', 'yellow', 'orange', 'red', 'purple', 'pink', 'coral', 'lime', 'indigo', 'teal'defaultfalseThe color of the icon
hasBackgroundbooleanfalsefalseAdds a filled colored background to the icon

Card.Label

nametypedefaultrequireddescription
childrenReactNode, ReactNode[]trueLabel content rendered above the heading
variant'token', 'accent-text'tokenfalsePresentation of the label above the heading

Forwards common span props such as className, id, and ref. variant="token" renders a Token, and variant="accent-text" renders EyebrowText with its accent presentation.

Card.Tokens

nametypedefaultrequireddescription
childrenReactNode, ReactNode[]trueTokens rendered inside the card
position'block-start', 'block-end'block-startfalsePlaces tokens at block-start or block-end relative to the copy

Card.Heading

nametypedefaultrequireddescription
as'h2', 'h3', 'h4', 'h5', 'h6'h3falseThe HTML tag to use for the heading
classNamestringfalseCustom class name for the heading component
childrenReactNode, ReactNode[]undefinedtrueContent to be displayed inside the heading component

Forwards all the props from the Heading component, including as, size, and weight.

Card.Description

nametypedefaultrequireddescription
childrenReactNode, ReactNode[]undefinedtrueContent to be displayed inside the card component

id, className and ref are forwarded by default to all children.