badge
draco-china-github/badgeFreeComponent
shadcn/ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/draco-china/shadcn-pro/main/apps/docs/public/r/styles/radix-sera/badge.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"3import { Slot } from "radix-ui"45import { cn } from "@/registry/radix-sera/lib/utils"67const badgeVariants = cva(8 "group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1.5 overflow-hidden rounded-none border-0 bg-transparent px-0 py-0 text-[0.625rem] font-semibold tracking-widest whitespace-nowrap uppercase transition-colors focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-0 has-data-[icon=inline-start]:pl-0 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",9 {10 variants: {11 variant: {12 default: "text-foreground [a]:hover:text-foreground/70",13 secondary: "text-muted-foreground [a]:hover:text-foreground",14 destructive:15 "text-destructive focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:text-destructive/70",16 outline: "text-foreground [a]:hover:text-foreground/70",17 ghost: "text-muted-foreground hover:text-foreground",18 link: "text-foreground underline-offset-4 hover:underline",19 },20 },21 defaultVariants: {22 variant: "default",23 },24 }25)2627function Badge({28 className,29 variant = "default",30 asChild = false,31 ...props32}: React.ComponentProps<"span"> &33 VariantProps<typeof badgeVariants> & { asChild?: boolean }) {34 const Comp = asChild ? Slot.Root : "span"3536 return (37 <Comp38 data-slot="badge"39 data-variant={variant}40 className={cn(badgeVariants({ variant }), className)}41 {...props}42 />43 )44}4546export { Badge, badgeVariants }
Files it writes
More from shadcn/ui
All 201 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn/ui | Components | Free | no deps | |
| alertalert | shadcn/ui | Components | Free | no deps | |
| alert-dialogalert-dialog | shadcn/ui | Components | Free | no deps | |
| aspect-ratioaspect-ratio | shadcn/ui | Components | Free | no deps | |
| avataravatar | shadcn/ui | Components | Free | no deps | |
| breadcrumbbreadcrumb | shadcn/ui | Components | Free | no deps | |
| buttonbutton | shadcn/ui | Components | Free | no deps | |
| button-groupbutton-group | shadcn/ui | Components | Free | no deps |
