badge
obsidianui/badgeFreeComponent
obsidianui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by obsidianui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://obsidianui.dev/r/badge.jsonSource
1import * as React from "react"2import { Slot } from "@radix-ui/react-slot"3import { cva, type VariantProps } from "class-variance-authority"45import { cn } from "@/lib/utils"67const badgeVariants = cva(8 "inline-flex items-center justify-center rounded-full 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 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 transition-[color,box-shadow] overflow-hidden",9 {10 variants: {11 variant: {12 default:13 "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",14 secondary:15 "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",16 destructive:17 "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",18 outline:19 "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",20 },21 },22 defaultVariants: {23 variant: "default",24 },25 }26)2728function Badge({29 className,30 variant,31 asChild = false,32 ...props33}: React.ComponentProps<"span"> &34 VariantProps<typeof badgeVariants> & { asChild?: boolean }) {35 const Comp = asChild ? Slot : "span"3637 return (38 <Comp39 data-slot="badge"40 className={cn(badgeVariants({ variant }), className)}41 {...props}42 />43 )44}4546export { Badge, badgeVariants }
What it pulls in
npm packages
Files it writes
More from obsidianui
All 111 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-inputai-input | obsidianui | Components | Free | 2 deps | |
| alertalert | obsidianui | Components | Free | no deps | |
| animated-tab-baranimated-tab-bar | obsidianui | Components | Free | no deps | |
| apple-spotlightapple-spotlight | obsidianui | Components | Free | 2 deps | |
| avataravatar | obsidianui | Components | Free | 1 dep | |
| breadcrumbbreadcrumb | obsidianui | Components | Free | 2 deps | |
| buttonbutton | obsidianui | Components | Free | 1 dep | |
| button-groupbutton-group | obsidianui | Components | Free | 1 dep |
