Skip to content
Sign upPro
SettingsSpend limitsMenu

Spend limits (Pro)

ProIncluded in $99

Caps per member and per agent: spend against each, the day it gets there, and what happens at the limit.

ProFour members and three agents mid month: one near, one past, one with no limit. Click an amount to edit it.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/spend-limits

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

tsx
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

ProLimits that add up past the workspace budget, and a read only narrow frame.

Props

PropTypeNotes
limitsSpendLimit[]{ id, name, kind, detail?, spent, cap, atCap? }
period{ start, end }For the forecast
budgetnumberThe workspace budget, to check the sum against
onCapChange(id, cap | null) => voidMakes amounts editable
onAtCapChange(id, mode) => voidShows the at the limit menu
currency, locale, nowFormatting and the forecast
labelsPartial<SpendLimitsLabels>Every string, for translation

Keyboard

KeyAction
EnterSave a limit
EscapeCancel 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.