Percent
Percent vs. percentage points, explicitly discriminated.
npx shadcn add @lopifi/percentExamples
The same component, case by case. Each stage is the shipped code with the props it shows; switch to Code for the usage.
Growth from zero
Growth from a zero base is unknowable, so it renders n/a — never Infinity, NaN or 100%.
How it behaves
What it renders, what it refuses to render, and why. The same paragraphs as the family spec, so the two can’t disagree.
Percent and percentage points are different numbers. This component won't let you mix them up.
<Percent value={{ kind: "relative", value: 25.0 }} /> // +25.0%
<Percent value={{ kind: "points", value: 5.0 }} /> // +5.0pp
<Percent value={{ kind: "bps", value: 25 }} /> // +25 bps
kind is required and has no default. Division by zero renders n/a, never Infinity.
Precision by kind: relative/points 1dp · bps 0dp · rate 3dp.
More in Primitives
See also
Where this component is specified, defined and running.
Elsewhere in the system
The live section Percent renders in, the calculators behind its figures, and the ledger payloads that feed it.
Components are copied into your repository and meant to be edited. Rounding policy, fiscal calendar and compliance copy differ per company.
Release notes
Get an email when Primitives changes
Your copy doesn’t update itself when we fix something here.
- One email when a Primitives component needs a migration
- Nothing when nothing changes
Or install it now