Single stat

Single stat is part of the design system extended layer 🤝 owned by groupoptimize. Questions or feedback? Reach out to #data-exploration-dashboards on Slack.

The single stat component displays the title and value of a metric.

Examples

Single stat
Loading live example...

Usage

A single stat can be used by itself or side-by-side with other single stats to display a topical set of metrics. There are a number of variations to allow for additional context or representation of the metric.

When to use a single stat

  • To show an overview of how a metric is performing.
  • To show multiple metrics around a similar topic side-by-side.

When not to use single stat

  • To display standard text or labels.
  • To display the same metric over a period of time (use a chart instead).

Demo

Simple

The default pattern for displaying a metric.

Simple
Loading live example...

Title icon

A single stat with a title icon to convey extra meaning to the metric.

Title icon
Loading live example...

Meta icon

A single stat with an icon which can be used to convey status or trend.

Meta icon
Loading live example...

Badge

A single stat with a badge which can be used to convey status or trend in more detail.

Badge
Loading live example...

The meta-tooltip prop adds a tooltip to the badge for additional context that doesn't fit in the badge text. When it's set, the badge is wrapped in a focusable button so the tooltip is reachable by keyboard and pointer. See the tooltip guidelines for what belongs in a tooltip.

Badge with a tooltip
Loading live example...

Description

A single stat with a description to add context to the metric.

Description
Loading live example...

The description wraps onto a maximum of two lines. When the text exceeds two lines, it's truncated and the full text is shown in a tooltip. See content truncation and overflow.

Drag the example below wider to see the truncation and tooltip resolve once the text fits.

Truncated description
Loading live example...

Supplementary content

A single stat with supplementary content, which renders below the value and above the description. The default slot accepts content such as a progress bar or a trend indicator.

Supplementary content
Loading live example...

Supplementary content can be combined with a description.

Supplementary content with a description
Loading live example...

A single stat that navigates to detailed information about a metric.

TODO:
Complete design spec and add "linked" single stat example. View issue

Design specifications

Color, spacing, dimension, and layout information can be viewed in the Pajamas UI Kit →

Code reference

The single stat component is used to show a single value. The color of the meta icon / badge is determined by the variant prop, which can be one of success, warning, danger, info, or neutral (default).

The description prop renders through GlTruncate using the lines and with-tooltip props, so the full text is shown in a tooltip only when the text is actually truncated.

Content passed to the default slot renders between the value and the description.

The meta-tooltip prop wraps the badge in a button element, which is what makes the tooltip keyboard accessible.

Hover state

You can make the component focusable by adding a tabindex=0 attribute to it. This will also apply a hover state to the component.

GlSingleStat

Loading story...

Last updated at: