BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/blode/ui/badge

Badge

blode-ui/badge
FreeComponent

A small status indicator for labelling and categorising items.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/mblode/blode-ui/main/public/r/badge.json

Source

ui/badge.tsxraw.githubusercontent.com/mblode/blode-ui/main/public/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";
4import type { VariantProps } from "class-variance-authority";
5import type * as React from "react";
6
7import { cn } from "@/lib/utils";
8
9const badgeVariants = cva(
10 "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-full border border-transparent px-2 py-0.5 font-medium text-xs transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
11 {
12 defaultVariants: {
13 variant: "default",
14 },
15 variants: {
16 variant: {
17 default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
18 destructive:
19 "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
20 ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
21 link: "text-primary underline-offset-4 [a&]:hover:underline",
22 outline:
23 "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
24 secondary: "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
25 success:
26 "bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300 [a&]:hover:bg-green-50/80 dark:[a&]:hover:bg-green-950/80",
27 warning:
28 "bg-yellow-50 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300 [a&]:hover:bg-yellow-50/80 dark:[a&]:hover:bg-yellow-950/80",
29 },
30 },
31 },
32);
33
34type BadgeProps = React.ComponentProps<"span"> &
35 VariantProps<typeof badgeVariants> & { asChild?: boolean };
36
37const Badge = ({
38 className,
39 variant = "default",
40 asChild = false,
41 children,
42 ...props
43}: BadgeProps) =>
44 useRender({
45 defaultTagName: "span",
46 props: mergeProps<"span">(
47 {
48 className: cn(badgeVariants({ variant }), className),
49 },
50 asChild ? props : { ...props, children },
51 ),
52 render: asChild ? (children as React.ReactElement) : undefined,
53 state: {
54 slot: "badge",
55 variant,
56 },
57 });
58
59export { Badge, badgeVariants };
60export type { BadgeProps };

What it pulls in

npm packages

  • @base-ui/react

Files it writes

  • registry/default/ui/badge.tsx

Facts

Registry
blode/ui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-01
Last confirmed
today

Go to the source

blode.co mblode/blode-ui on GitHub Raw registry item This item as JSON

More from blode/ui

All 85 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionblode/uiComponentsFree2 deps
Alertalertblode/uiComponentsFreeno deps
Alert Dialogalert-dialogblode/uiComponentsFree1 dep
Ask User Questionsask-user-questionsblode/uiComponentsFree1 dep
Aspect Ratioaspect-ratioblode/uiComponentsFree1 dep
Attachmentattachmentblode/uiComponentsFree1 dep
Autocompleteautocompleteblode/uiComponentsFree1 dep
Avataravatarblode/uiComponentsFree1 dep
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