badge
9ui/badgeFreeComponent
9ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by 9ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://9ui.dev/r/badge.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"34import { cn } from "@/lib/utils"56const badgeVariants = cva(7 "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none overflow-hidden shadow-xs",8 {9 variants: {10 variant: {11 default: "bg-primary border-transparent text-primary-foreground",12 outline: "text-foreground",13 secondary: "bg-secondary border-border/50 text-secondary-foreground",14 success: "bg-success border-success-border/50 text-success-foreground",15 warning: "bg-warning border-warning-border/50 text-warning-foreground",16 info: "bg-info border-info-border/50 text-info-foreground",17 danger: "bg-danger border-danger-border/50 text-danger-foreground",18 },19 },20 defaultVariants: {21 variant: "default",22 },23 }24)2526function Badge({27 className,28 variant,29 ...props30}: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {31 return (32 <span33 data-slot="badge"34 className={cn(badgeVariants({ variant }), className)}35 {...props}36 />37 )38}3940export { Badge, badgeVariants }
Files it writes
More from 9ui
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | 9ui | Components | Free | no deps | |
| alertalert | 9ui | Components | Free | no deps | |
| alert-dialogalert-dialog | 9ui | Components | Free | no deps | |
| aspect-ratioaspect-ratio | 9ui | Components | Free | no deps | |
| autocompleteautocomplete | 9ui | Components | Free | no deps | |
| avataravatar | 9ui | Components | Free | no deps | |
| breadcrumbsbreadcrumbs | 9ui | Components | Free | no deps | |
| buttonbutton | 9ui | Components | Free | no deps |
