Components / data

Tally

A row of counts, each one a way in: a number, a picture and a word that open the list the number counts.

Rendered from the package · open on its own

Summary

A row of counts, each one a way in: a number, a picture and a word that open the list the number counts.

APG patternnone
Built onnative elements
Statusself-tested
Since0.14.0
<Tally
  label="Needs your attention"
  items={[
    { key: 'security', label: 'Security', count: 1, icon: <Icon path={shieldWarning} />, onClick: () => open('security') },
    { key: 'bills', label: 'Bills', count: 1, icon: <Icon path={receipt} />, onClick: () => open('bills') },
    { key: 'prep', label: 'Prep', count: 3, icon: <Icon path={shoppingCart} />, href: '/prep' },
  ]}
/>

One count that does nothing is a Stat. Several that do nothing are a StatGroup.

Anatomy

A <ul data-se="tally"> of <li>, each holding one <button> or <a> with data-part="item". The item holds label, count and an optional icon. The DOM order is label first, so a screen reader hears Security, 1; the CSS draws the count first, the icon under it and the word last.

PartElementRequired
count<span>yes
icon<span>no
item<control>yes
label<span>yes
<ul data-se="tally" aria-label="Needs your attention">
  <li>
    <button type="button" data-part="item" aria-haspopup="dialog">
      <span data-part="label" data-se-text="caption">Security</span>
      <span data-part="count" data-se-text="subheading">1</span>
      <span data-part="icon" aria-hidden="true"><svg>…</svg></span>
    </button>
  </li>
</ul>

The <li> carries no part: it is the list's own element, and the item inside it is the control. The roles are part of the anatomy: subheading on the count and caption on the label. The icon is decoration and is hidden from a reader.

Properties

PropertyValuesDefaultWhat it does
labelstringrequiredThe list's accessible name: what the counts are of. A list a reader can land on needs one.
itemsTallyItem[]requiredOne entry per count.

States

StateExpressed as
Focused:focus-visible
Hover:hover

A tally has no state of its own. What an item opens, and whether it is open, is the caller's: an item that opens a dialog says so with aria-haspopup="dialog", which is passed through to the control.

Behavior

An item is a native <button> or <a>, and does what a button or a link does. Nothing counts up or flashes when a count changes: a number that moves is a number the reader has to wait for. The items wrap into as many columns as fit, and no item is narrower than a fifth of --se-col-min, 2.8rem at the template, so six sit in one row on a 390px phone.

Accessibility

The list is named. label becomes the list's accessible name, so a reader landing on it hears Needs your attention, list, 6 items. A list of controls a reader can land on needs one.

Each item is one reading, label then count. Security, 1. A number read before its word is a number without meaning until the next word arrives.

The icon is hidden. It repeats what the label says, so it is aria-hidden.

A count that needs hearing when it changes is not announced here. A tally refreshing on a timer would otherwise announce itself every tick. The caller says so with an Alert.

Keyboard

KeyDoes
TabMoves to the next item. Each item is its own tab stop: it is a list of separate controls, not one widget with arrow keys.
Enter, SpaceActivates a button item. Enter follows a link item.

Roles, states and properties

AttributeSet by
aria-hiddenalways true
aria-labelset at render

Focus

Focus lands on the item, and the ring is drawn on it with the contract's focus tokens. The ring is never clipped: nothing in a tally hides overflow.

Screen reader

Not recorded as verified. Stage 4 of the readiness ladder — driving each component with VoiceOver and NVDA — is unstarted across the package, and no component should claim otherwise until docs/journal/ records the session that did it.

Contrast and target size

npm run check:contrast audits every color pair this component uses across all four skins, light and dark, and fails the build on a shortfall. Two waivers are on the record in docs/audit/DEFERRED.md.

It takes the touch floor under (pointer: coarse) — the visual size is unchanged on a desktop pointer.

An item is at least --se-target-min tall under a coarse pointer. On a fine pointer it is as tall as its content, which is the count, the icon and the word and their spacing.

Tested

  • test/apg/tally.test.jsx
  • test/browser/tally.spec.mjs

Known gaps

_No upstream requirement is recorded as not applicable._

Appearance

The count takes the subheading role's step through data-se-text, at the bold weight, in tabular figures. The label takes the caption role and the muted color. The icon takes the muted color and the large icon box. The items sit on a grid of equal columns with --se-space-1 between them.

TokenUsed for
--se-col-mingrid-template-columns
--se-duration-instanttransition
--se-ease-standardtransition
--se-focus-coloroutline
--se-focus-offsetoutline-offset
--se-focus-widthoutline
--se-icon-lgblock-size, inline-size
--se-icon-smblock-size, font-size, inline-size
--se-radius-cardborder-radius
--se-space-1gap, padding
--se-space-2padding, row-gap
--se-surface-sunkbackground
--se-target-minmin-block-size
--se-textcolor
--se-text-mutedcolor
--se-weight-boldfont-weight

No border and no surface. The hover tint, --se-surface-sunk, is the only thing that says an item is a control on a pointer that can hover; the focus ring says where it is. A tally on a card sits inside the card's padding and draws no frame of its own.

Motion

The hover tint changes over --se-duration-instant. Nothing else moves.

Content

The label is the thing counted, one word. Security, Bills, Returns. Not Security alerts that need you.

The count is formatted for reading. 1, 12, 99+. A count that is zero is shown as 0, not left out: an empty list is information.

The icon is a picture of the thing, not of the action. A shield for Security, a receipt for Bills.

Usage

Use it for a few counts that each open something. Six at most reads as a row; beyond that, a DataTable or a Listbox.

An item that changes the address is a link, and one that opens something in place is a button. The same line Button and Link draw.

When not to use it. For a number that does nothing, Stat. For a filter with no count, Chip. For a choice of one, SegmentedControl or RadioGroup.

Notes

Found on the Daily Brief. Its Needs your attention card is a count over an icon over a label, six across, each opening a list. It was hand-built in the app; the design owner asked for the pattern to move into the system (docs/proposals/2026-11-03-daily-brief-layout-patterns.md, P2).

DOM order label-first, visual order count-first. The same choice Stat made, for the same reason: the cost is a grid, which is a CSS decision and not a contract one.

The floor is a share of the column floor, not a fixed length. calc(var(--se-col-min) / 5), so a skin that widens its columns widens the floor. It is not --se-target-min: that token is only read inside a coarse-pointer block, a house rule batch-a holds.