BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/optics/badge

Badge

optics/badge
FreeComponent

Displays a badge or a component that looks like a badge.

See it running

Open the demo on optics

optics.agusmayol.com.ar/components/badge
Open
This registry sends X-Frame-Options, so its page cannot be embedded here. The link is the same page the frame would have shown.

Install it

npx shadcn@latest add https://optics.agusmayol.com.ar/r/badge.json

Source

registry/optics/badge.jsxoptics.agusmayol.com.ar/r/badge.json
1import { mergeProps } from "@base-ui/react/merge-props";
2import { useRender } from "@base-ui/react/use-render";
3import { cva } from "class-variance-authority";
4
5import { cn } from "@/lib/utils";
6
7const badgeVariants = cva(
8 "h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! 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 transition-colors overflow-hidden group/badge",
9 {
10 variants: {
11 variant: {
12 default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
13 secondary:
14 "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
15 destructive:
16 "bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",
17 outline:
18 "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",
19 ghost:
20 "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
21 link: "text-primary underline-offset-4 hover:underline",
22 },
23 },
24 defaultVariants: {
25 variant: "default",
26 },
27 },
28);
29
30function Badge({
31 className = "",
32 variant = "default",
33 render = undefined,
34 ...props
35}) {
36 return useRender({
37 defaultTagName: "span",
38 props: mergeProps(
39 {
40 className: cn(badgeVariants({ className, variant })),
41 },
42 props,
43 ),
44 render,
45 state: {
46 slot: "badge",
47 variant,
48 },
49 });
50}
51
52Badge.displayName = "Badge";
53
54export { Badge, badgeVariants };

What it pulls in

npm packages

  • @base-ui/react
  • class-variance-authority
  • clsx
  • tailwind-merge

Other registry items

  • https://optics.agusmayol.com.ar/r/utils.json

Files it writes

  • registry/optics/badge.jsx

Facts

Registry
optics
Type
registry:component
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-04
Last confirmed
today

Go to the source

Docs on optics optics.agusmayol.com.ar AgusMayol/optics on GitHub Raw registry item This item as JSON

More from optics

All 79 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionopticsComponentsFree5 deps
AlertalertopticsComponentsFree4 deps
Alert Dialogalert-dialogopticsComponentsFree4 deps
Aspect Ratioaspect-ratioopticsComponentsFree2 deps
Auto Heightauto-heightopticsComponentsFree3 deps
AvataravataropticsComponentsFree3 deps
BreadcrumbbreadcrumbopticsComponentsFree4 deps
ButtonbuttonopticsComponentsFree4 deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex