{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "usage-meter-02",
  "description": "Storage used as a ring in its status colour, with the space that is free.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/animated-number.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/ring.json",
    "https://www.dashboardblocks.com/r/radix/usage-meter.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/usage-meter/usage-meter-02.tsx",
      "content": "'use client'\n\nimport { AnimatedNumber } from '@/registry/components/dashboardblocks/animated-number'\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport { Ring } from '@/registry/components/dashboardblocks/ring'\nimport {\n  UsageMeterLimit,\n  UsageMeterValue,\n  UsageStatusLabel,\n  formatUsage,\n  getUsageShare,\n  getUsageStatus,\n  usageStatusConfig,\n} from '@/registry/components/dashboardblocks/usage-meter'\nimport { formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface UsageMeter2Props extends BlockStateProps {\n  limit: number\n  title: string\n  unit: string\n  /** Leave out to show the empty state. */\n  used?: number\n}\n\nconst exampleProps: UsageMeter2Props = {\n  limit: 120,\n  title: 'Storage',\n  unit: 'GB',\n  used: 78.4,\n}\n\nconst UsageMeter2 = (props: UsageMeter2Props) => {\n  const { limit, errorMessage, status: blockStatus, title, unit, used = 0 } = props\n  const share = getUsageShare(used, limit)\n  const status = getUsageStatus(used, limit)\n  const free = Math.max(0, limit - used)\n\n  return (\n    <BlockStateProvider\n      errorMessage={errorMessage}\n      state={getBlockState(blockStatus, props.used)}\n    >\n      <Card>\n        <CardContent>\n          <section className='@container flex items-center gap-6 border-t pt-4 in-data-[slot=card]:first:border-t-0 in-data-[slot=card]:first:pt-0'>\n            <Ring\n              ariaLabel={`${formatPercent(share / 100, { maximumFractionDigits: 0 })} of ${title.toLowerCase()} used`}\n              className='size-24'\n              percentage={Math.min(100, share)}\n              ringColor={usageStatusConfig[status].color}\n              strokeWidth={8}\n            >\n              <AnimatedNumber\n                className='text-2xl font-light tracking-tight tabular-nums'\n                value={Math.round(share)}\n                formatter={(value) =>\n                  formatPercent(value / 100, { maximumFractionDigits: 0 })\n                }\n              />\n            </Ring>\n            <div className='flex min-w-0 flex-col gap-1'>\n              <p className='text-muted-foreground text-sm'>{title}</p>\n              <div className='flex flex-wrap items-baseline gap-x-1.5'>\n                <UsageMeterValue>{formatUsage(used, unit)}</UsageMeterValue>\n                <UsageMeterLimit>of {formatUsage(limit, unit)}</UsageMeterLimit>\n              </div>\n              <BlockReady className='text-sm'>\n                <Details className='text-muted-foreground block text-sm'>\n                  <span>\n                    <span className='tabular-nums'>{formatUsage(free, unit)}</span> free\n                  </span>\n                  {status !== 'ok' && <UsageStatusLabel variant='text' status={status} />}\n                </Details>\n              </BlockReady>\n            </div>\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { UsageMeter2, exampleProps as usageMeter2ExampleProps, type UsageMeter2Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/usage-meter/usage-meter-02.tsx"
    }
  ],
  "meta": {
    "shows": "Storage used as a ring in its status colour, with the space that is free.",
    "size": "compact",
    "usedWith": [
      "usage-meter-05",
      "files-01",
      "usage-meter-06"
    ],
    "component": "UsageMeter2",
    "props": "{ limit: number; title: string; unit: string; used?: number; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
