{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "usage-meter-06",
  "description": "Every limit on a plan, flagging the ones nearly reached and prompting an upgrade.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/usage-meter.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/usage-meter/usage-meter-06.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  UsageBar,\n  UsageStatusLabel,\n  formatUsage,\n  getUsageStatus,\n} from '@/registry/components/dashboardblocks/usage-meter'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport type { ReactNode } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface PlanLimit {\n  icon: ReactNode\n  limit: number\n  name: string\n  unit?: string\n  used: number\n}\n\ninterface UsageMeter6Props extends BlockStateProps {\n  /** Leave out, or pass none, to show the empty state. */\n  limits?: PlanLimit[]\n  onUpgrade?: () => void\n  plan: string\n}\n\nconst exampleProps: UsageMeter6Props = {\n  limits: [\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='UsersIcon'\n          tabler='IconUsers'\n          hugeicons='UserGroupIcon'\n          phosphor='UsersIcon'\n          remixicon='RiTeamLine'\n        />\n      ),\n      limit: 5,\n      name: 'Team members',\n      used: 4,\n    },\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='ZapIcon'\n          tabler='IconBolt'\n          hugeicons='FlashIcon'\n          phosphor='LightningIcon'\n          remixicon='RiFlashlightLine'\n        />\n      ),\n      limit: 10_000,\n      name: 'API calls',\n      used: 6_120,\n    },\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='DatabaseIcon'\n          tabler='IconDatabase'\n          hugeicons='Database01Icon'\n          phosphor='DatabaseIcon'\n          remixicon='RiDatabase2Line'\n        />\n      ),\n      limit: 5,\n      name: 'Storage',\n      unit: 'GB',\n      used: 4.9,\n    },\n    {\n      icon: (\n        <IconPlaceholder\n          lucide='MailIcon'\n          tabler='IconMail'\n          hugeicons='MailIcon'\n          phosphor='EnvelopeIcon'\n          remixicon='RiMailLine'\n        />\n      ),\n      limit: 1_000,\n      name: 'Emails sent',\n      used: 450,\n    },\n  ],\n  onUpgrade: () => {},\n  plan: 'Pro',\n}\n\nconst UsageMeter6 = (props: UsageMeter6Props) => {\n  const { limits = [], onUpgrade, plan, errorMessage, status: blockStatus } = props\n  const state = getBlockState(blockStatus, limits)\n  const nearLimit = limits.filter(\n    (item) => getUsageStatus(item.used, item.limit) !== 'ok',\n  )\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-3'>\n            <header className='flex items-start justify-between gap-3'>\n              <div className='flex min-w-0 flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{plan} plan</h2>\n                <BlockReady className='text-sm'>\n                  <p className='text-muted-foreground text-sm'>\n                    {nearLimit.length === 0\n                      ? 'Every limit has room this month.'\n                      : nearLimit.length === 1\n                        ? `${nearLimit[0].name} is nearly at its limit this month.`\n                        : `${nearLimit.length} of ${limits.length} limits are nearly reached this month.`}\n                  </p>\n                </BlockReady>\n              </div>\n              {onUpgrade && (\n                <Button\n                  className='shrink-0'\n                  onClick={onUpgrade}\n                  size='sm'\n                  variant={nearLimit.length > 0 ? 'default' : 'outline'}\n                >\n                  Upgrade\n                </Button>\n              )}\n            </header>\n            {state && <BlockStateRows className='border-t' rows={4} />}\n            {!state && (\n              <ul className='flex flex-col border-t'>\n                {limits.map((item) => {\n                  const status = getUsageStatus(item.used, item.limit)\n                  return (\n                    <li\n                      key={item.name}\n                      className='flex flex-col gap-2 border-b py-2.5 last:border-b-0'\n                    >\n                      <div className='flex items-center justify-between gap-3 text-sm'>\n                        <span className='text-muted-foreground flex min-w-0 items-center gap-2 [&_svg]:size-4 [&_svg]:shrink-0'>\n                          {item.icon}\n                          <span className='text-foreground truncate'>{item.name}</span>\n                        </span>\n                        <span className='flex shrink-0 items-baseline gap-3 text-xs'>\n                          {status !== 'ok' && (\n                            <UsageStatusLabel className='text-xs' status={status} />\n                          )}\n                          <span className='text-muted-foreground tabular-nums'>\n                            <span className='text-foreground font-medium'>\n                              {formatUsage(item.used)}\n                            </span>{' '}\n                            of {formatUsage(item.limit, item.unit, { compact: true })}\n                          </span>\n                        </span>\n                      </div>\n                      <UsageBar limit={item.limit} size='sm' used={item.used} />\n                    </li>\n                  )\n                })}\n              </ul>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  UsageMeter6,\n  exampleProps as usageMeter6ExampleProps,\n  type PlanLimit,\n  type UsageMeter6Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/usage-meter/usage-meter-06.tsx"
    }
  ],
  "meta": {
    "shows": "Every limit on a plan, flagging the ones nearly reached and prompting an upgrade.",
    "size": "compact",
    "usedWith": [
      "billing-01",
      "usage-meter-01",
      "usage-meter-03"
    ],
    "component": "UsageMeter6",
    "props": "{ limits?: { icon: ReactNode; limit: number; name: string; unit?: string; used: number }[]; onUpgrade?: () => void; plan: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
