{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "workflow-status",
  "type": "registry:ui",
  "title": "Workflow Status",
  "description": "Compact workflow badges with semantic defaults, custom states, icon and colour overrides, two sizes, and an icon-only form.",
  "author": "Aditya Ojha <https://akoder.xyz>",
  "categories": [
    "status",
    "workflow",
    "badge",
    "accessibility"
  ],
  "dependencies": [
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "registryDependencies": [],
  "meta": {
    "docs": "https://akoder.xyz/components/workflow-status",
    "source": "https://github.com/AdityaKodez/adityaojha/blob/main/components/ui/workflow-status.tsx"
  },
  "files": [
    {
      "path": "components/ui/workflow-status.tsx",
      "content": "import { clsx, type ClassValue } from \"clsx\";\nimport {\n  AlertTriangle,\n  CheckCircle2,\n  CircleDashed,\n  CircleX,\n  Clock3,\n  ScanSearch,\n  Send,\n  type LucideIcon\n} from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport const workflowStatuses = [\n  \"pending\",\n  \"in-progress\",\n  \"submitted\",\n  \"in-review\",\n  \"success\",\n  \"failed\",\n  \"expired\",\n] as const;\n\nexport type WorkflowStatus = (typeof workflowStatuses)[number];\nexport type WorkflowStatusValue = WorkflowStatus | (string & {});\nexport type WorkflowStatusBadgeSize = \"sm\" | \"default\";\n\nexport interface WorkflowStatusBadgeProps extends ComponentProps<\"span\"> {\n  status: WorkflowStatusValue;\n  /** Overrides the default or inferred label for the selected state. */\n  label?: string;\n  /** Replaces the state's default icon. */\n  icon?: LucideIcon;\n  /** Replaces the state's background and foreground colour classes. */\n  colorClassName?: string;\n  /** Adds classes to the icon. */\n  iconClassName?: string;\n  /** Reduces the badge footprint for dense interfaces. */\n  size?: WorkflowStatusBadgeSize;\n  /**\n   * Shows the icon-only form. The state label stays in the accessibility tree\n   * as visually hidden text, so no aria-label is required.\n   */\n  iconOnly?: boolean;\n}\n\ntype StatusPresentation = {\n  label: string;\n  icon: LucideIcon;\n  className: string;\n  iconClassName?: string;\n};\n\nexport const workflowStatusPresentations: Record<\n  WorkflowStatus,\n  StatusPresentation\n> = {\n  pending: {\n    label: \"Pending\",\n    icon: AlertTriangle,\n    className: \"bg-amber-500/12 text-amber-700 dark:text-amber-300\",\n  },\n  \"in-progress\": {\n    label: \"In progress\",\n    icon: CircleDashed,\n    className: \"bg-sky-500/12 text-sky-700 dark:text-sky-300\",\n  },\n  submitted: {\n    label: \"Submitted\",\n    icon: Send,\n    className: \"bg-violet-500/12 text-violet-700 dark:text-violet-300\",\n  },\n  \"in-review\": {\n    label: \"In review\",\n    icon: ScanSearch,\n    className: \"bg-yellow-500/12 text-yellow-700 dark:text-yellow-300\",\n  },\n  success: {\n    label: \"Success\",\n    icon: CheckCircle2,\n    className: \"bg-emerald-500/12 text-emerald-700 dark:text-emerald-300\",\n  },\n  failed: {\n    label: \"Failed\",\n    icon: CircleX,\n    className: \"bg-rose-500/12 text-rose-700 dark:text-rose-300\",\n  },\n  expired: {\n    label: \"Expired\",\n    icon: Clock3,\n    className: \"bg-zinc-500/12 text-zinc-700 dark:text-zinc-300\",\n  },\n};\n\n/** Default label for a state. Useful for filters and legends built alongside the badge. */\nexport function getWorkflowStatusLabel(status: WorkflowStatusValue): string {\n  return isWorkflowStatus(status)\n    ? workflowStatusPresentations[status].label\n    : humanizeStatus(status);\n}\n\nfunction isWorkflowStatus(status: WorkflowStatusValue): status is WorkflowStatus {\n  return status in workflowStatusPresentations;\n}\n\nfunction humanizeStatus(status: string) {\n  const label = status.trim().replace(/[-_]+/g, \" \");\n  return label ? label.charAt(0).toUpperCase() + label.slice(1) : \"Status\";\n}\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\n/**\n * A compact semantic label for workflow states. Each state has an icon, colour,\n * and accessible text without requiring a separate icon library or stylesheet.\n */\nexport function WorkflowStatusBadge({\n  status,\n  label,\n  icon,\n  colorClassName,\n  iconClassName,\n  size = \"default\",\n  iconOnly = false,\n  className,\n  ...props\n}: WorkflowStatusBadgeProps) {\n  const presentation = isWorkflowStatus(status)\n    ? workflowStatusPresentations[status]\n    : undefined;\n  const Icon = icon ?? presentation?.icon ?? CircleDashed;\n  const resolvedLabel = label ?? presentation?.label ?? humanizeStatus(status);\n\n  return (\n    <span\n      data-status={status}\n      className={cn(\n        \"inline-flex shrink-0 items-center justify-center font-medium tracking-tight\",\n        iconOnly\n          ? size === \"sm\"\n            ? \"size-6 rounded-full\"\n            : \"size-8 rounded-full\"\n          : size === \"sm\"\n            ? \"min-h-6 gap-1 rounded-lg px-2 py-1 text-xs\"\n            : \"min-h-8 gap-1.5 rounded-xl px-3 py-1.5 text-sm\",\n        colorClassName ??\n          presentation?.className ??\n          \"bg-muted text-muted-foreground\",\n        className,\n      )}\n      {...props}\n    >\n      <Icon\n        aria-hidden=\"true\"\n        strokeWidth={2.25}\n        className={cn(\n          \"shrink-0 motion-reduce:animate-none\",\n          size === \"sm\" ? \"size-3.5\" : \"size-4.5\",\n          presentation?.iconClassName,\n          iconClassName,\n        )}\n      />\n      {iconOnly ? <span className=\"sr-only\">{resolvedLabel}</span> : resolvedLabel}\n    </span>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "docs": "## Installation\n\n```bash\nnpx shadcn@latest add @akoder/workflow-status\n```\n\n## Usage\n\n```tsx\nimport { WorkflowStatusBadge } from \"@/components/ui/workflow-status\";\n\nexport function DeploymentState() {\n  return <WorkflowStatusBadge status=\"in-progress\" />;\n}\n```\n\nPass any of the built-in semantic states: `pending`, `in-progress`, `submitted`, `in-review`, `success`, `failed`, or `expired`. Use `label` for product-specific language, or `iconOnly` for compact interface areas."
}