{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"readme-badge","type":"registry:component","title":"Readme Badge","description":"Renders a shieldcn badge image with optional link wrapping. Works with any badge URL — shieldcn, shields.io, or custom images.","dependencies":[],"registryDependencies":[],"categories":["badges","readme"],"files":[{"path":"registry/readme-badge/readme-badge.tsx","type":"registry:component","content":"/**\n * shieldcn\n * ReadmeBadge\n * by Justin Levine\n * shieldcn.dev\n *\n * Renders a shieldcn badge image with optional link wrapping.\n * Works with any shieldcn badge URL or any image URL.\n *\n * Props:\n * - src: badge image URL (shieldcn, shields.io, or any image)\n * - alt: accessible alt text for the badge\n * - href?: optional link URL — wraps the badge in an anchor tag\n * - height?: image height in pixels (default 20)\n * - className?: class name for the outer element (link or image)\n * - imgClassName?: class name for the img element (when href is set)\n */\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\ninterface ReadmeBadgeProps extends React.ComponentProps<\"img\"> {\n  /** Badge image URL. */\n  src: string\n  /** Accessible alt text. */\n  alt: string\n  /** Optional link — wraps badge in an anchor. */\n  href?: string\n  /** Image height in pixels. @default 20 */\n  height?: number\n  /** Class name for the outer element. */\n  className?: string\n  /** Class name for the img element when wrapped in a link. */\n  imgClassName?: string\n}\n\nfunction ReadmeBadge({\n  src,\n  alt,\n  href,\n  height = 20,\n  className,\n  imgClassName,\n  ...props\n}: ReadmeBadgeProps) {\n  const img = (\n    // eslint-disable-next-line @next/next/no-img-element\n    <img\n      src={src}\n      alt={alt}\n      height={height}\n      className={cn(\n        \"inline-block align-middle\",\n        href ? imgClassName : className\n      )}\n      loading=\"lazy\"\n      decoding=\"async\"\n      {...props}\n    />\n  )\n\n  if (href) {\n    return (\n      <a\n        href={href}\n        target=\"_blank\"\n        rel=\"noopener noreferrer\"\n        className={cn(\"inline-flex\", className)}\n      >\n        {img}\n      </a>\n    )\n  }\n\n  return img\n}\n\nexport { ReadmeBadge }\nexport type { ReadmeBadgeProps }\n"}]}