Nasaq
Components

BreakdownTable

A top-N table where each row carries a bar sized against the largest value, with share and change against the previous period.

PreviewOpen ↗

Code

import { BreakdownTable } from "@fadymondy/nasaq/web";export function Channels() {  return (    <BreakdownTable      title="Channels"      dimensionLabel="Channel"      valueLabel="Sessions"      rows={[        { id: "organic", label: "Organic Search", value: 28100, previous: 24800 },        { id: "direct", label: "Direct", value: 13400, previous: 14100 },      ]}    />  );}

Analytics · beta

Live examples and controls: BreakdownTable in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/breakdown-table.json

BreakdownTable answers "what makes up this number?": traffic channels, source / medium, top pages, devices, traffic sources. Rows are sorted by value, each has a bar sized against the largest, a share of the total and, when previous is given, the change. Long lists collapse to limit rows with a "Show all" button.

When to use

  • Top-N lists in an analytics report.
  • Any single-measure ranking that benefits from a bar.
  • Adding extra columns with columns.

When not to use

Import

import { BreakdownTable } from "@fadymondy/nasaq/web";

Quick start

import { BreakdownTable } from "@fadymondy/nasaq/web";

export function Channels() {
  return (
    <BreakdownTable
      title="Channels"
      dimensionLabel="Channel"
      valueLabel="Sessions"
      rows={[
        { id: "organic", label: "Organic Search", value: 28100, previous: 24800 },
        { id: "direct", label: "Direct", value: 13400, previous: 14100 },
      ]}
    />
  );
}

Anatomy

BreakdownTable         data-slot="breakdown-table"  (a Card)
  Table                label, value, share, change and extra columns
    row bar            data-slot="breakdown-bar"
  Show all button      when there are more than `limit` rows

API

BreakdownTable

PropTypeDefaultDescription
rowsreadonly BreakdownRow[]required{ id, label, value, previous?, href? }. Sorted by value.
dimensionLabelReactNoderequiredHeading of the first column.
valueLabelReactNoderequiredHeading of the value column.
title / description / actionReactNodenoneCard header.
formatFormatNumberOptionsnoneIntl options for values.
limitnumber8Rows shown before "Show all".
showSharebooleantrueShare-of-total column (hidden on narrow screens).
invertbooleanfalseDown is good for the change column.
colorstringvar(--primary)Bar colour, a token.
ltrLabelsbooleanfalseKeep labels left-to-right in RTL: URLs, paths, source / medium.
columnsreadonly BreakdownColumn[]noneExtra columns: { id, header, cell(row), align? }.
labelstringtitleAccessible name of the table.
loadingbooleanfalseSkeleton rows.
classNamestringnoneExtra classes on the root.
labelsPartial<BreakdownTableLabels>noneReplace any built-in English or Arabic string.

Examples

URLs stay left-to-right:

import { BreakdownTable } from "@fadymondy/nasaq/web";

export const Pages = () => <BreakdownTable title="Top pages" dimensionLabel="Page" valueLabel="Sessions" ltrLabels rows={[{ id: "a", label: "/docs/getting-started", value: 4210, href: "/docs/getting-started" }]} />;

An extra column:

import { BreakdownTable } from "@fadymondy/nasaq/web";

export const Videos = () => (
  <BreakdownTable
    title="Top videos"
    dimensionLabel="Video"
    valueLabel="Views"
    showShare={false}
    rows={[{ id: "v1", label: "RTL dashboard in 20 minutes", value: 18400 }]}
    columns={[{ id: "watch", header: "Watch time (h)", align: "end", cell: () => "612" }]}
  />
);

Arabic:

import { BreakdownTable } from "@fadymondy/nasaq/web";

export const Ar = () => <BreakdownTable title="القنوات" dimensionLabel="القناة" valueLabel="الجلسات" rows={[{ id: "o", label: "البحث المجاني", value: 28100, previous: 24800 }]} />;

Accessibility

A real table with column headers and a name from label or title. Bars are decorative (aria-hidden); the values and shares are text. The change is a signed percentage, toned green or red, never colour alone. Links are ordinary anchors.

RTL & i18n

  • Columns and bars run from the inline start; the value columns align to the end.
  • Set ltrLabels for URLs and source / medium so they are not reordered.
  • Every figure uses the active locale with Western digits and is bidi-isolated (Num), so +12.4% keeps its order in Arabic.

Styling & tokens

  • Colours come from tokens (--primary, --nq-success, --nq-warning, --nq-danger, --nq-tag-*); never pass raw hex.
  • Bar track uses --nq-surface-soft; up and down use --nq-success-text and --nq-danger-text.

Do / Don't

  • Do give previous so users see movement.
  • Do use ltrLabels for paths and URLs.
  • Don't use it for more than one measure.
  • Don't set limit above about 15; link to a full report instead.

Lab

https://docs.nasaqui.com/?path=/docs/components-analytics-breakdown-table--docs

On this page