fma-ds

Stat Cards

Totals above a list or on a dashboard: figures on their own or on cards that are static, pressable, links or filters.

originalMITexperimentalChangelogRegistry JSON

Overview

Stat

A label (StatLabel), a value (StatValue, formatted by the app, with isLoading and isUnavailable states), an optional StatIcon (a soft IconTile) and a StatDescription.

  • `tone`: default, success, warning, info, destructive or muted; tints the icon and the value.
  • `size="lg"`: enlarges the value.

On its own, Stat has no surface, for several figures inside one card.

Cards

  • `StatCard`: static.
  • `StatCardButton`: runs onPress, or opens a dialog as the child of a DialogTrigger.
  • `StatCardLink`: navigates, e.g. to the list already filtered.
  • `StatCardToggle`: the selectable cards of a StatCardGroup, a react-aria ToggleButtonGroup that filters a list. selectionMode="single" behaves like radios and "multiple" like checkboxes, controlled by selectedKeys/onSelectionChange so it maps to a search param.

StatGrid and StatCardGroup lay cards out in as many columns as fit, and their i18n.labels reach every value inside.

Installation

  1. 1

    Register the @fma-ds namespace in components.json (once)

    components.json
    {  "registries": {    "@fma-ds": "https://ds.fmartinsandre.dev.br/r/{name}.json"  }}
  2. 2

    Add the item

    pnpm dlx shadcn@latest add @fma-ds/stat-cards

    Files land in components/fma-ds/stat-cards/stat-cards.tsx; npm and registry dependencies are installed along with them.

Dependencies

npm
class-variance-authority@^0.7.1cn@^0.5.0react-aria-components@^1.22.1