PeakUIPro

KPIGroup

Several metrics on one surface

Usage

import {KPIGroup} from "@peakui-pro/react";

Anatomy

import {KPIGroup} from "@peakui-pro/react";

// The group ships from the package root: it imports no chart, so laying out metrics needs no
// charting library. Inside it a KPI card gives up its own background, shadow and radius — one
// surface, with a hairline between the metrics.
export default () => (
  <KPIGroup aria-label="Email metrics">
    <KPIGroup.Separator />
  </KPIGroup>
);

Examples

With From Suffix

Vertical

Customization

Tailwind CSS

<KPIGroup aria-label="Monthly totals" className="max-w-96" />

Global CSS

@layer components {
  .kpi-group {
    --kpi-group-separator-color: var(--border-secondary);
    --kpi-group-separator-inset: calc(var(--spacing) * 6);
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The KPIGroup component uses these CSS classes (view source styles):

Base & Orientation Classes

  • .kpi-group - The shared surface; the cards inside it drop their own
  • .kpi-group--horizontal - Metrics side by side, each taking an equal share of the width
  • .kpi-group--vertical - Metrics stacked

Element Classes

  • .kpi-group__separator - The hairline between two metrics

Slots

  • [data-slot="kpi-group"] - The group
  • [data-slot="kpi-group-separator"] - A hairline

CSS Variables

VariablePurpose
--kpi-group-separator-colorColour of the hairline
--kpi-group-separator-insetHow far a vertical hairline stops short of the group's edges

API Reference

KPIGroup

PropTypeDefaultDescription
orientation'horizontal' | 'vertical''horizontal'Which way the metrics are laid out, and which way the hairlines run
childrenReactNode-The metrics and the hairlines between them
aria-labelstring-Names the set; each card inside already names its own metric
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element
...restComponentProps<'div'>-Native <div> attributes. role is group and can be overridden

KPIGroup.Separator

PropTypeDefaultDescription
aria-hiddenbooleantrueHidden by default: it is decoration between metrics that already name themselves
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element
...restComponentProps<'span'>-Native <span> attributes

On this page