Badge
tdds/badgeFreeComponent
Treasury-themed status badges
Install it
npx shadcn@latest add https://raw.githubusercontent.com/gjohnsx/ttb-label-verification/main/tdds-registry/public/r/badge.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"3import { Slot } from "radix-ui"45import { cn } from "@/lib/utils"67const badgeVariants = cva(8 "h-5 gap-1 rounded-[5px] border px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive overflow-hidden group/badge",9 {10 variants: {11 variant: {12 default: "bg-primary text-primary-foreground border-transparent [a]:hover:bg-primary/80",13 secondary: "bg-secondary text-secondary-foreground border-transparent [a]:hover:bg-secondary/80",14 destructive: "bg-destructive/10 border-transparent [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",15 outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",16 ghost: "border-transparent hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",17 link: "border-transparent text-primary underline-offset-4 hover:underline",18 // Treasury themed variants with lightest bg + border19 "treasury-primary": "bg-treasury-primary-lightest text-treasury-primary-dark border-treasury-primary",20 "treasury-secondary": "bg-treasury-secondary-lightest text-treasury-secondary-dark border-treasury-secondary",21 "treasury-accent": "bg-treasury-accent-lightest text-treasury-accent-dark border-treasury-accent",22 "treasury-warning": "bg-treasury-warning-lightest text-treasury-warning-dark border-treasury-warning",23 "treasury-base": "bg-treasury-base-lightest text-treasury-base-dark border-treasury-base",24 },25 },26 defaultVariants: {27 variant: "default",28 },29 }30)3132function Badge({33 className,34 variant = "default",35 asChild = false,36 ...props37}: React.ComponentProps<"span"> &38 VariantProps<typeof badgeVariants> & { asChild?: boolean }) {39 const Comp = asChild ? Slot.Root : "span"4041 return (42 <Comp43 data-slot="badge"44 data-variant={variant}45 className={cn(badgeVariants({ variant }), className)}46 {...props}47 />48 )49}5051// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from tdds
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | tdds | Components | Free | 2 deps | |
| Alertalert | tdds | Components | Free | 1 dep | |
| Alert Dialogalert-dialog | tdds | Components | Free | 1 dep | |
| Avataravatar | tdds | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | tdds | Components | Free | 2 deps | |
| Buttonbutton | tdds | Components | Free | 2 deps | |
| Button Groupbutton-group | tdds | Components | Free | 1 dep | |
| Cardcard | tdds | Components | Free | no deps |
