BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn-htmx/badge

Badge

shadcn-htmx/badge
FreeComponent

Small visual marker — status pill / counter / label. Six variants; renders as span (default) or anchor (with href).

Live preview

live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/badge.json

Source

registry/ui/badge.tsxshadcn-htmx.productdevbook.com/r/badge.json
1/** @jsxImportSource hono/jsx */
2import type { PropsWithChildren } from "hono/jsx"
3import { cloneElement, isValidElement } from "hono/jsx"
4import { cn, type ClassValue } from "@/registry/lib/cn"
5
6// Badge — shadcn-htmx, htmx v4 + Tailwind v4.
7//
8// Source of truth (variants + base class 1:1):
9// repos/shadcn-ui/apps/v4/registry/new-york-v4/ui/badge.tsx
10//
11// A non-interactive visual marker. Renders as <span> by default. Pass
12// `as="a"` (or `asChild` with a child anchor) to make it a link — the
13// upstream uses Radix Slot.Root; we use cloneElement.
14//
15// Accessibility:
16// - The badge's content (text) IS the accessible name. If you render an
17// icon-only badge, set `ariaLabel` so screen readers can name it.
18// - Status-style badges ("New", "3 unread") that update in place should
19// live inside an aria-live region (use Alert / Toast for that, not
20// Badge). Badge itself is presentational.
21// - See repos/mdn/files/en-us/web/html/reference/elements/span/index.md for
22// <span> semantics (none — it's a generic inline container).
23
24export type BadgeVariant =
25 | "default"
26 | "secondary"
27 | "destructive"
28 | "outline"
29 | "ghost"
30 | "link"
31
32const base =
33 "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] " +
34 "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 " +
35 "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 " +
36 "[&>svg]:pointer-events-none [&>svg]:size-3"
37
38const variants: Record<BadgeVariant, string> = {
39 default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
40 secondary: "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
41 destructive:
42 "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
43 outline:
44 "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
45 ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
46 link: "text-primary underline-offset-4 [a&]:hover:underline",
47}
48
49export function badgeClasses(opts?: {
50 variant?: BadgeVariant
51 class?: ClassValue
52}): string {
53 const variant = opts?.variant ?? "default"
54 return cn(base, variants[variant], opts?.class)
55}
56
57type BadgeProps = PropsWithChildren<{
58// … truncated

Facts

Registry
shadcn-htmx
Type
registry:ui
Access
Free
Files written
0
Licence
MIT
In the index
at or before 2026-08-12
Last confirmed
yesterday

Go to the source

Docs on shadcn-htmx shadcn-htmx.productdevbook.com productdevbook/shadcn-htmx on GitHub Raw registry item This item as JSON

More from shadcn-htmx

All 83 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Accordionaccordionshadcn-htmxComponentsFreeno deps
Active Searchactive-searchshadcn-htmxComponentsFreeno deps
Alertalertshadcn-htmxComponentsFreeno deps
Alert Dialogalert-dialogshadcn-htmxComponentsFreeno deps
Aspect Ratioaspect-ratioshadcn-htmxComponentsFreeno deps
Auto Gridauto-gridshadcn-htmxComponentsFreeno deps
Autocompleteautocompleteshadcn-htmxComponentsFreeno deps
Autosize Textareaautosize-textareashadcn-htmxComponentsFreeno deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex