Skip to content
synccn

Usage Meter

New

Plan quota bar: amber near the limit, red with the overage once passed, unlimited state and a compact list size.

Usage this period

Nov 1 – Nov 30 · Pro plan

API requests412K / 1M
Resets Dec 1
Bandwidth86.4 / 100 GB
86% used · Resets Dec 1Upgrade
Build minutes6.5K / 6K
480 over the limit · $0.01 per extra minuteUpgrade
Seats
7 / 10
Projects
23

Installation

$ pnpm dlx shadcn@latest add @synccn/usage-meter

First time in this project? Connect synccn with one command.

Usage

import { UsageMeter, usageStatus } from "@/components/ui/usage-meter";<UsageMeter label="API requests" value={842000} limit={1000000} hint="Resets Dec 1" />

API reference

Generated from the component's TypeScript types, so it always matches the code.

UsageMeter

Quota bar for plans and billing: used of limit, amber near the limit, red with the overage once it's passed, and an "unlimited" state. Uses role meter with readable values.

  • labelrequired
    React.ReactNode

    What's being measured, e.g. "API requests".

  • valuerequired
    number

    Amount used so far.

  • limitrequired
    number | null

    The plan's limit. Pass null for unlimited.

  • unit
    string

    Unit after the numbers, e.g. "GB".

  • format
    (n: number) => string

    Default compact

    Formats numbers. Defaults to compact notation: 1.2k, 3.4M.

  • warnAt
    number

    Default 0.8

    Share of the limit at which the meter turns amber, from 0 to 1.

  • hint
    React.ReactNode

    Small print under the bar, such as "Resets Dec 1".

  • action
    React.ReactNode

    Something to do about it, such as an Upgrade link, shown when the meter is amber or over.

  • size
    "default" | "compact"

    Default "default"

    "default" stacks the label over the bar; "compact" fits on one line for lists.

  • className
    string

    Extra classes for the root element.

usageStatus

Works out the meter's state, so you can show the same thing elsewhere (a badge, an email).

Takes no props.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

  • Uses role meter with aria-valuetext such as "842K of 1M, 12K over the limit", so the state isn't conveyed by colour alone.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: meter
  • ARIA attributes: aria-label, aria-valuemax, aria-valuemin, aria-valuenow, aria-valuetext