Skip to content

The open alternative to Salesforce, designed for AI.

3.0 KB
Raw Blame
---
title: MetricRow
description: Align a metric label and formatted value with optional progress.
---

import { PageBanner } from "/snippets/page-banner.mdx"

import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import MetricRowReference from '/snippets/ui/generated/components/data-display/metric-row.mdx';

## Overview

`MetricRow` aligns a label, optional icon, and preformatted value. An optional [ProgressRing](/ui/primitives/feedback/progress-ring) uses the visible label as its accessible name.

<StoryEmbed
  storyId="ui-data-display-metricrow--display"
  title="Metric row example"
  height={100}
/>

## Usage

```tsx
import { MetricRow } from 'twenty-ui/components/data-display';
import { IconFiles } from 'twenty-ui/icon';

export const ImportMetric = () => (
  <MetricRow
    startIcon={<IconFiles size={14} />}
    value="75 of 100"
    progress={75}
  >
    Imported files
  </MetricRow>
);
```

Pass a nonempty text label as required children and the formatted value through `value`. Add `progress` when the metric has a known percentage.

The application owns calculations, units, number formatting, and the meaning of the metric. `progressColor` accepts a CSS color for the filled arc.

## Values without progress

Omit `progress` to show a plain value. Numeric zero displays as `0`; content is never replaced with a placeholder. Supply your own placeholder when data is unavailable.

```tsx
import { MetricRow } from 'twenty-ui/components/data-display';

export const CompletedMetric = () => (
  <MetricRow value={0}>Completed imports</MetricRow>
);
```

## Composition and accessibility

Label content accepts nodes. Its accessible text names the progress ring through `aria-labelledby`, including nested text. Provide a meaningful visible label. A nonempty string value is also exposed as its accessible value text. For formatted value content, supply `progressValueText` when a percentage does not describe the metric fully. This text overrides the string value fallback. Without it, other content keeps the ring's percentage value text. An empty `progressValueText` also uses the percentage, including when `value` is a string. The optional `startIcon` node is decorative. The caller controls its dimensions and stroke.

```tsx
import { MetricRow } from 'twenty-ui/components/data-display';
import { Text } from 'twenty-ui/primitives/typography';

export const FormattedStorageMetric = () => (
  <MetricRow
    value={<Text render={<bdi />}>12 / 20 GB</Text>}
    progress={60}
    progressValueText="12 of 20 gigabytes used"
  >
    <Text render={<strong />}>Storage</Text>
  </MetricRow>
);
```

Replace `startIcon={IconDatabase}` with `startIcon={<IconDatabase size={14} />}`. Values stay preformatted by the application.

Native attributes, `className`, `style`, and `ref` target the outer row. `render` can replace that element. Progress stays controlled and bounded to 0 to 100, with the same reduced-motion behavior as `ProgressRing`.

## Props

<MetricRowReference />

<PageBanner illustration="dashboards" />