Staaarter

Billing Usage Cap Settings

A settings panel for letting customers control their own spending on metered resources. Two number inputs set an alert threshold and a hard cap, a switch turns on automatic throttling once the hard cap is hit, and a Save button confirms the change. The alert threshold is validated against the hard cap before saving is allowed.

By Staaarter Team
Billing
Updated July 2, 2026
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, input, label dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/billing-usage-cap-settings.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing146.tsx instead.

Usage

The file also exports billing146Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Billing146, billing146Demo } from "@/components/blocks/billing/billing146";

export default function Page() {
  return <Billing146 {...billing146Demo} />;
}

Props

PropTypeDefaultDescription
headingstring"Usage cap settings"Heading at the top of the panel.
descriptionstringnoneOptional one-line note under the heading.
resourceLabelstring"API credits"Name of the metered resource, used in the threshold label and throttle copy.
currentUsageNotestringnoneOptional line showing how much has been used so far this cycle.
currencySymbolstring"$"Symbol shown before both number inputs.
defaultSoftCapnumbernoneStarting value of the alert-threshold input.
defaultHardCapnumbernoneStarting value of the hard-cap input.
defaultThrottleEnabledbooleanfalseWhether the automatic-throttle switch starts on.
saveLabelstring"Save changes"Label on the save button.
classNamestringnoneExtra classes for the outer container.

Behavior notes

  • Both cap fields and the throttle switch are local state; editing any of them clears the 'Saved' confirmation shown after a prior save.
  • Save is blocked, and the button disabled, whenever the alert threshold is entered higher than the hard cap; an inline error explains why.
  • Clicking Save only flips a local 'saved' flag that shows a checkmark and 'Saved' text, no network request is made. Wire handleSave's call site to your API to actually persist the values.
  • The throttle switch is a hand-built button with role="switch" and aria-checked, matching the toggle pattern used elsewhere in this category, since the UI kit has no Switch primitive.
  • Both number inputs use type="number" with inputMode="decimal" so mobile keyboards show a numeric pad, but the component does not clamp typed values beyond the soft-cap-vs-hard-cap check.

Frequently asked questions