Spend limits (Pro)
ProIncluded in $99Caps per member and per agent: spend against each, the day it gets there, and what happens at the limit.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { SpendLimits } from "@/components/ui/chatcn/pro/spend-limits"
<SpendLimits
limits={[
{ id: "priya", kind: "member", name: "Priya Raman", detail: "priya@northwind.dev", spent: 264, cap: 300, atCap: "approve" },
{ id: "evals", kind: "agent", name: "Nightly evals", detail: "Runs at 02:00", spent: 188, cap: 200, atCap: "pause" },
]}
period={{ start, end }}
budget={1500}
onCapChange={(id, cap) => saveCap(id, cap)} // cap is null for no limit
onAtCapChange={(id, mode) => saveMode(id, mode)} // "pause" | "alert" | "approve"
/>Members and agents sit on two tabs. Each row shows what was spent against its limit with a bar that turns amber near it and red past it, and, at the pace so far this period, the day it gets there. What happens at the limit is set per row: pause new requests, keep running and alert admins, or make each request wait for an admin; a row past its limit says which one happened. Click the amount to edit the limit in place (Enter saves, Escape cancels, No limit removes it). With budget, limits that add up past the workspace budget are pointed out once. Pair it with budget-guard for the workspace cap itself.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
limits | SpendLimit[] | { id, name, kind, detail?, spent, cap, atCap? } |
period | { start, end } | For the forecast |
budget | number | The workspace budget, to check the sum against |
onCapChange | (id, cap | null) => void | Makes amounts editable |
onAtCapChange | (id, mode) => void | Shows the at the limit menu |
currency, locale, now | Formatting and the forecast | |
labels | Partial<SpendLimitsLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Enter | Save a limit |
| Escape | Cancel editing |
Accessibility
- Amounts are buttons named with the person and the current limit.
- The at the limit menu is a radio group with a line on what each choice does.
- A reached limit is a status message, in words as well as color.
Motion
None.