{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kpi-03",
  "description": "A rate beside its previous value, with the change in percentage points.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/kpi.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/kpi/kpi-03.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  KPI,\n  KPIChange,\n  KPIContent,\n  KPITitle,\n  type KPIFormat,\n  KPIValue,\n} from '@/registry/components/dashboardblocks/kpi'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface KPI3Props extends BlockStateProps {\n  /** Use `points` for rates, so the change reads in percentage points; 'percent' by default. */\n  changeType?: 'percent' | 'points'\n  comparison: string\n  /** @default 'This month' */\n  currentLabel?: string\n  format?: KPIFormat\n  /** Use `down` for metrics like churn, where a decrease is good. */\n  goodDirection?: 'up' | 'down'\n  previous?: number\n  title: string\n  /** Leave out to show the empty state. */\n  value?: number\n}\n\nconst exampleProps: KPI3Props = {\n  changeType: 'points',\n  comparison: 'last month',\n  format: 'percent',\n  previous: 3.46,\n  title: 'Conversion rate',\n  value: 3.24,\n}\n\nconst KPI3 = (props: KPI3Props) => {\n  const {\n    changeType,\n    comparison,\n    currentLabel = 'This month',\n    format,\n    goodDirection,\n    previous,\n    errorMessage,\n    status,\n    title,\n    value,\n  } = props\n  const state = getBlockState(status, value)\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <KPI>\n            <KPIContent className='gap-1'>\n              <KPITitle>{title}</KPITitle>\n              <div className='flex flex-wrap items-end gap-x-6 gap-y-1'>\n                <div className='flex flex-col'>\n                  <KPIValue value={value} format={format} animated />\n                  <span className='text-muted-foreground text-xs'>{currentLabel}</span>\n                </div>\n                {(state === undefined || state === 'loading') && (\n                  <div className='text-muted-foreground flex flex-col pb-px'>\n                    <KPIValue className='text-2xl' value={previous} format={format} />\n                    <span className='text-xs first-letter:uppercase'>{comparison}</span>\n                  </div>\n                )}\n              </div>\n              <KPIChange\n                className='mt-2'\n                changeType={changeType}\n                comparison={comparison}\n                goodDirection={goodDirection}\n                previous={previous}\n                value={value}\n                variant='short'\n              />\n            </KPIContent>\n          </KPI>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { KPI3, exampleProps as kpi3ExampleProps, type KPI3Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/kpi/kpi-03.tsx"
    }
  ],
  "meta": {
    "shows": "A rate beside its previous value, with the change in percentage points.",
    "size": "compact",
    "usedWith": [
      "kpi-02",
      "funnel-01",
      "chart-panel-01"
    ],
    "component": "KPI3",
    "props": "{ changeType?: \"percent\" | \"points\"; comparison: string; currentLabel?: string; format?: \"number\" | \"compact\" | \"currency\" | \"currency-compact\" | \"percent\"; goodDirection?: \"up\" | \"down\"; previous?: number; title: string; value?: number; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
