BadgePreview

Visual badge preview with live rendering and copyable code snippet.

Installation

pnpm dlx shadcn@latest add @shieldcn/badge-preview

Usage

import { BadgePreview } from "@/components/badge-preview"

Basic preview

badge preview
<BadgePreview src="https://shieldcn.dev/npm/react.svg" alt="React" />

With code snippet

Shows a copyable code block below the badge preview.

badge preview
![React](https://shieldcn.dev/npm/react.svg?variant=branded)

With label

badge preview
![stars](https://shieldcn.dev/github/stars/vercel/next.js.svg?variant=outline)

Dark and light modes

badge preview
/npm/react.svg
badge preview
/npm/react.svg?mode=light

Variant grid

Use BadgePreviewGroup and BadgePreviewCard to show multiple variants:

badge preview
/npm/react.svg
badge preview
/npm/react.svg?variant=branded
badge preview
/npm/react.svg?variant=outline
badge preview
/npm/react.svg?variant=ghost

API Reference

BadgePreview

PropType