Skip to main content
MediaCard
@coinbase/cds-web@8.52.2
MediaCard displays content with optional media in a contained card layout. Use it to showcase assets, products, or content with a thumbnail, title, subtitle, description, and optional media placement. MediaCard replaces the deprecated FloatingAssetCard and ContainedAssetCard components.
import { MediaCard } from '@coinbase/cds-web/cards/MediaCard'
Related components

MediaCard provides a contained card layout with optional media, ideal for showcasing assets, products, or promotional content.

Migrating from FloatingAssetCard or ContainedAssetCard?

See the Migration Guide at the end of this page.

Basic

At minimum, provide a thumbnail to display visual content and a title for the card heading.

Loading...

Media Placement

Use the media prop to display larger visual content. Control its position with mediaPlacement:

  • start: Media on the left
  • end (default): Media on the right
Loading...

Polymorphic and Interactive

MediaCard supports polymorphic rendering and can be made interactive with renderAsPressable. Use as to change the underlying element.

Loading...

Text Content

Long Text

The card handles long text content with truncation.

Loading...

Custom Content

Use React nodes for custom styled text content.

Loading...

Styling

Use styles and classNames props to customize specific parts of the card.

Loading...

Multiple Cards

Display multiple cards in a carousel.

Loading...

Accessibility

Interactive Cards

When making MediaCard interactive with renderAsPressable:

  • If as is set to "button" or "a", renderAsPressable defaults to true automatically. Add an accessibilityLabel to summarize the card's action for screen reader users (e.g., accessibilityLabel="View Ethereum details")
Avoid Nested Interactive Elements

Don't place buttons or links inside an interactive card, as this creates accessibility issues for screen reader users and can cause unexpected behavior when clicking.

Heading Semantics

By default, the title prop renders as a <div>. If you need the title to be a proper heading element for document structure, pass a custom Text node with the as prop:

<MediaCard
title={
<Text as="h3" font="headline">
Card Title
</Text>
}
// ...other props
/>

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.

Migration from Deprecated Components

Migrating from ContainedAssetCard

Replace ContainedAssetCard with MediaCard:

// Before
<ContainedAssetCard
header={<RemoteImage source={assets.btc.imageUrl} width="32px" height="32px" />}
title="$309.43"
subtitle="Bitcoin"
description={<Text color="fgPositive">&#x2197;3.37%</Text>}
size="l"
>
<RemoteImage source={ethBackground} ... />
</ContainedAssetCard>

// After
<MediaCard
thumbnail={<RemoteImage source={assets.btc.imageUrl} shape="circle" size="l" />}
title="$309.43"
subtitle="Bitcoin"
description={<Text color="fgPositive">&#x2197;3.37%</Text>}
media={<RemoteImage src={ethBackground} height="100%" width="100%" resizeMode="cover" />}
mediaPlacement="end"
/>

Migrating from FloatingAssetCard

Replace FloatingAssetCard with MediaCard. Note that the floating variation (media outside the card container) is no longer supported:

// Before
<FloatingAssetCard
title="Balancing the Air"
subtitle="Amber V's Artwork"
description="0.5 ETH"
media={<RemoteImage source="/img/nft.png" ... />}
/>

// After
<MediaCard
thumbnail={<RemoteImage source="/img/nft.png" shape="circle" size="l" />}
title="Balancing the Air"
subtitle="Amber V's Artwork"
description="0.5 ETH"
/>

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.