4.2.0
Patterns

SpendBar

Usage against a cap, with the cap state stated rather than derived.

Default

The ordinary case: a number, its cap, and the state a policy says that number is in.

Spend180 / 1,000

18% used · This month

Usage

import { SpendBar } from '@oceanic-hub/brand-system'

One of four meters, and the four answer four questions. Progress marks a task with an end — it has a finish line, and 100 means done. EngagementBar measures a rate, how often rather than how much, with no finish line at all. FitScore renders a 0–100 score. This one measures a quantity against a policy-set cap, and alone among the four it carries a cap-state of its own — the other three have no equivalent, because none of them has a ceiling to be near.

Oceanic-only, and shadcn's progress docs page is a nearest relative at best, not a counterpart to pair against: its own examples are a bare value, a label-and-value composition, a slider-controlled bar and an RTL demo — nothing about a budget, a cap, or a state a caller supplies rather than computes. A reader who wants generic task completeness reaches for Progress instead; this component is not a smaller Progress, it answers a different question.

capState is deliberately supplied rather than computed from used / cap: where "near" starts is a policy decision that belongs to the product, and a component that guesses it will be wrong in one product and unfixable in the other. See spend-bar.contract.test-d.ts for the full argument — it is the model for how this repo argues a prop shape.

format denominates the numbers; the default names no currency, on purpose — see the demo below. hideLabel drops the footer caption, and is safe exactly when the number is already stated beside the bar, the same condition EngagementBar's hideValue carries for its own footer.

Cap states

The threshold is a policy, not arithmetic — the surface says which side of it this number is on, so two products with the same numbers can still disagree about when to warn.

Spend180 / 1,000

18% used · This month

Spend840 / 1,000

84% used · This month

Spend1,180 / 1,000

100% used · This month

Denominating the numbers

The default names no currency. format is the seam — pass it to denominate.

Spend840 / 1,000

84% used · no currency (default)

Spend€840 / €1000

84% used · euros

Spend840 cr / 1,000 cr

84% used · credits

In a compact list

Pass hideLabel when the row already states the number beside the bar — a list of workspaces, say — so the "% used · cap" caption is not repeated once per row.

Northwind62% used
Spend620 / 1,000
PadelSwift86% used
Spend860 / 1,000
Riverside Clinic124% used
Spend1,240 / 1,000

API Reference

See the SpendBar API page for every prop of every part, with types, defaults and the contract that pins them.

On this page