Skip to main content
ContentCard
@coinbase/cds-web@8.47.1
A flexible card component for displaying content.
import { ContentCard } from '@coinbase/cds-web/cards/ContentCard'

ContentCard is a flexible, composable card component built with ContentCardHeader, ContentCardBody, and ContentCardFooter sub-components. It can display various content layouts including text, media, and interactive elements.

Semantic HTML

ContentCard and its sub-components render semantic HTML elements by default:

  • ContentCard renders as <article>
  • ContentCardHeader renders as <header>
  • ContentCardFooter renders as <footer>

You can override these defaults using the as prop on each component.

Basic Examples

ContentCard uses sub-components for flexible layout. Combine ContentCardHeader, ContentCardBody, and ContentCardFooter to create your card structure.

Loading...

Media Placement

Use the mediaPlacement prop on ContentCardBody to control where media is positioned relative to the content.

Loading...

With Background

Apply a background color to the card using the background prop. When using a background, consider using variant="tertiary" on buttons.

Loading...

Rewards Card Example

Example showing a rewards-style content card with claim button.

Loading...

Accessibility

Interactive Cards

When making ContentCard interactive, wrap it in a Pressable component and handle accessibility carefully to avoid nested interactive elements.

The Problem: If you wrap ContentCard in a Pressable and also have interactive elements inside (like buttons), the card becomes a clickable container with nested interactive elements. This creates accessibility issues for screen reader users.

The Solution: Use as="div" on the Pressable wrapper and add a separate action button inside the card. This allows:

  • Regular users to click anywhere on the card
  • Screen reader users to navigate through card content and focus on individual interactive elements
  • Keyboard users to tab to the action button
Loading...

Key points:

  • Use as="div" on the Pressable to avoid rendering as a semantic button
  • When using as="div", the Pressable remains keyboard focusable. Set tabIndex={-1} to remove it from the tab order if needed
  • Call event.stopPropagation() at the beginning of the event handler method passed into the onClick prop for action buttons. This will prevent two click events from firing if the user directly clicks the action button.
Avoid Nested Interactive Elements

When ContentCard is wrapped in an interactive Pressable, avoid placing too many interactive elements inside the card. Each interactive element should have a clear, distinct purpose. If the card has many actions, consider using a non-interactive card layout instead.

Color Contrast

When customizing card backgrounds, ensure sufficient color contrast between text and background colors. Use tools like the WebAIM Contrast Checker to verify your color combinations meet WCAG guidelines.

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.