A few numbers about one thing, such as a customer's plan and seats, as small tiles.
- 1.0 kB JS 2.6 kB CSS gzipped
- No serious axe issues
- Server-rendered, hydrates
- 44px touch targets
- Right-to-left
- 10 tests
- Plan
- BusinessAnnual, renews 1 March
- Seats
- 48 of 502 left
- Lifetime value
- $148,200
- Open tickets
- 31 breached SLA
- CSAT
- 94%+3 pts this quarter
- Customer since
- Aug 2021
import type { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { FactGrid } from "./ui/uicontext/components/FactGrid.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ wrap: { inlineSize: "min(100%, 30rem)" } })// a customer's account at a glance, in a help desk's side panelexport const AccountFacts = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.wrap)).children( FactGrid(h, { label: "Northwind Traders", facts: [ { label: "Plan", value: "Business", hint: "Annual, renews 1 March" }, { label: "Seats", value: "48 of 50", tone: "warning", hint: "2 left" }, { label: "Lifetime value", value: "$148,200" }, { label: "Open tickets", value: "3", hint: "1 breached SLA", tone: "danger" }, { label: "CSAT", value: "94%", tone: "success", hint: "+3 pts this quarter" }, { label: "Customer since", value: "Aug 2021" }, ], }), )When to use
A few numbers about one thing, such as a customer's plan and seats, as small tiles. Use Stat instead when the numbers are a dashboard's headline, with trends.
Usage
import { FactGrid } from "./ui/uicontext/components/FactGrid.ts"export const Account = <M>(h: Html.H<M>) => FactGrid(h, { label: "Account", facts: [{ label: "Plan", value: "Business" }, { label: "Seats", value: "48 of 50", tone: "warning" }] })Examples
Plain, inside a card
variant: "plain" drops the tile borders; columns caps how many fit in a row.
Support triage agent · December
- Runs
- 12,408+18% vs Nov
- Success rate
- 97.2%
- Median time
- 4.1s
- Cost
- $318.40Budget $500
import type { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { FactGrid } from "./ui/uicontext/components/FactGrid.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, corner, font, space, stroke } from "./ui/uicontext/components/tokens.stylex.ts"const styles = stylex.create({ card: { display: "grid", gap: space.lg, inlineSize: "min(100%, 36rem)", padding: space.lg, borderWidth: stroke.hairline, borderStyle: "solid", borderColor: color.line, borderRadius: corner.card, backgroundColor: color.panel }, title: { margin: 0, fontSize: font.base, fontWeight: 600 },})// an agent's usage this month, plain inside its card, four across with larger valuesexport const AgentUsage = <M>(h: Html.H<M>) => h.section.attrs(sx(styles.card)).children( h.h3.attrs(sx(styles.title)).children("Support triage agent · December"), FactGrid(h, { label: "Usage this month", variant: "plain", size: "lg", columns: 4, facts: [ { label: "Runs", value: "12,408", hint: "+18% vs Nov" }, { label: "Success rate", value: "97.2%", tone: "success" }, { label: "Median time", value: "4.1s" }, { label: "Cost", value: "$318.40", hint: "Budget $500" }, ], }), )API reference
Options
| Name | Type | Default | Description |
|---|---|---|---|
label | string | — | What the facts are about: "Account", "This agent". |
factsrequired | Fact<Message>[] | — | The tiles, in order. |
columns | number | 3 | The most tiles in a row; 3 by default. |
minWidth | number | 120 | A tile's narrowest width, in px, before the row wraps; 120 by default. |
variant | "tiles" | "plain" | — | tiles (the default) on a bordered surface, or plain with no border, for inside a card. |
size | "md" | "lg" | — | A larger value, for the facts at the top of a page. |
style | Style | — | — |
Installation
pnpm dlx shadcn@latest add checkfu/uicontext/fact-grid