mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-11-03 03:18:52 +00:00
Upstream sync from shadcn-ui/ui (1686 commits since last merge base). Key changes: - packages/shadcn upgraded to 4.1.0 (CLI font transformers, scaffold from github, chart colors) - apps/v4 replaces apps/www as the primary docs/registry app - Font system: 25+ heading font registries, font markers utility, @supports override - Chart improvements: recharts v3 compat, radial chart fixes - templates/ updated with monorepo variants (astro, vite, react-router, start) - skills/shadcn AI skill definitions added - deprecated/ removed (auth, auth-firebase, cli, www) Preserved Hanzo-only paths: app/, pkg/, demo/, docs/, template/next/
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import * as React from "react"
|
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
import { Slot } from "radix-ui"
|
|
|
|
import { cn } from "@/registry/bases/radix/lib/utils"
|
|
|
|
const badgeVariants = cva(
|
|
"cn-badge group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default: "cn-badge-variant-default",
|
|
secondary: "cn-badge-variant-secondary",
|
|
destructive: "cn-badge-variant-destructive",
|
|
outline: "cn-badge-variant-outline",
|
|
ghost: "cn-badge-variant-ghost",
|
|
link: "cn-badge-variant-link",
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
},
|
|
}
|
|
)
|
|
|
|
function Badge({
|
|
className,
|
|
variant = "default",
|
|
asChild = false,
|
|
...props
|
|
}: React.ComponentProps<"span"> &
|
|
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
const Comp = asChild ? Slot.Root : "span"
|
|
|
|
return (
|
|
<Comp
|
|
data-slot="badge"
|
|
data-variant={variant}
|
|
className={cn(badgeVariants({ variant }), className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export { Badge, badgeVariants }
|