Skip to main content
DataCard
@coinbase/cds-web@8.52.2
A flexible card component for displaying data with visualizations like progress bars and circles. It supports horizontal and vertical layouts with customizable thumbnails and title accessories.
import { DataCard } from '@coinbase/cds-web/alpha/data-card'

DataCard is a flexible card component for displaying data with visualizations. It provides a structured layout for thumbnails, titles, subtitles, and visualization content. Pass any visualization component as children, such as ProgressBar, ProgressCircle, LineChart, or custom content.

Migrating from Legacy DataCard?

See the Migration Guide at the end of this page.

Basic Examples

DataCard supports two layouts: vertical (stacked) and horizontal (side-by-side). Pass visualization components as children.

Loading...

With LineChart

DataCard can also display chart visualizations like LineChart for showing price trends or time-series data.

Loading...

Layout Variations

Use layout="vertical" for stacked layouts (thumbnail on left, visualization below) or layout="horizontal" for side-by-side layouts (header on left, visualization on right).

Loading...

Title Accessory

Use titleAccessory to display supplementary information inline with the title, such as trends, percentages, or status indicators.

Loading...

Interactive Cards

Use renderAsPressable to make the card interactive. You can render as a button with onClick or as a link with as="a" and href.

Loading...

Style Customization

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

Loading...

Multiple Cards

DataCards work well in lists or dashboards to display multiple data points.

Loading...

Accessibility

Ensure all visualization components have appropriate accessibilityLabel props to convey the progress information to screen readers.

Interactive Cards

When making DataCard interactive with renderAsPressable:

  • If as is set to "button" or "a", renderAsPressable defaults to true automatically. Add an accessibilityLabel to summarize the card's content for screen reader users, ensuring all visual text of the card is included in the label (e.g., accessibilityLabel="ETH Holdings, 45% progress, View details")
Loading...
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:

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

Color Contrast for Gain/Loss Text

When displaying gain or loss percentages in DataCard, be aware of color contrast differences between light and dark modes.

Why this matters: DataCard uses bgAlternate as its background color. In light mode, the semantic fgPositive token does not meet WCAG AA contrast requirements:

ModeColorBackgroundContrast RatioWCAG AA (4.5:1)
LightfgPositive (green60)bgAlternate (gray10)~3.6:1❌ Fails
Lightgreen70bgAlternate (gray10)~4.8:1✅ Passes
DarkfgPositive (green60)bgAlternate (gray5)~6.2:1✅ Passes

Recommendation:

  • Light mode: Use green70 for positive values instead of fgPositive
  • Dark mode: fgPositive meets WCAG AA requirements and can be used as-is
  • Both modes: fgNegative meets WCAG AA requirements

On web, use CSS variables for light mode compatibility:

{
/* Gain text */
}
<Text dangerouslySetColor="rgb(var(--green70))" font="label1">
↗ 12.5%
</Text>;

{
/* Loss text */
}
<Text color="fgNegative" font="label1">
↘ 3.2%
</Text>;
Loading...

Migration from Legacy DataCard

The new DataCard from @coinbase/cds-web/alpha/data-card replaces the legacy DataCard. The new version provides more flexibility with custom layouts and visualization components.

Before:

import { DataCard } from '@coinbase/cds-web/cards/DataCard';

<DataCard
title="Progress"
description="45% complete"
progress={0.45}
progressVariant="bar"
startLabel={45}
/>;

After:

import { DataCard } from '@coinbase/cds-web/alpha/data-card';

<DataCard
title="Progress"
subtitle="45% complete"
layout="vertical"
thumbnail={<RemoteImage src={assetUrl} shape="circle" size="l" />}
>
<Box paddingTop={6}>
<ProgressBarWithFixedLabels
startLabel={{
value: 45,
render: (num) => (
<Text color="fgMuted" font="legal">
{num}%
</Text>
),
}}
labelPlacement="below"
>
<ProgressBar accessibilityLabel="45% complete" progress={0.45} weight="semiheavy" />
</ProgressBarWithFixedLabels>
</Box>
</DataCard>;

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.