Badge

A compact badge component for labeling content, with six visual variants and Base UI render customization. It renders as a `<span>` by default and applies its variant and caller-provided classes.

Badge
LIVE · running in a sandboxed iframe
Installed with shadcn add · 1 workaround · theme from the install docs
  • applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
See how it was built

Installation

pnpm dlx shadcn@latest add https://neobrutalism.com/r/badge.json

Usage

usage.tsx
import { Badge } from "@/components/ui/badge"export function BadgeExamples() {  return (    <div className="flex gap-2">      <Badge>New</Badge>      <Badge variant="secondary">In progress</Badge>      <Badge variant="destructive">Needs attention</Badge>    </div>  )}
  • Show a short status, category, or metadata label next to content.
  • Distinguish labels with the default, secondary, destructive, outline, ghost, or link color treatment.
  • Render a badge with an alternate element or custom rendering behavior using the Base UI `render` prop.

Examples

Default label

Use the default primary treatment for a short label.

default-label.tsx
import { Badge } from "@/components/ui/badge"export function NewBadge() {  return <Badge>New</Badge>}

Status label

Choose a variant to distinguish a status visually.

status-label.tsx
import { Badge } from "@/components/ui/badge"export function StatusBadge() {  return <Badge variant="destructive">Needs attention</Badge>}

Outline label

Use the outline treatment for a quieter category label.

outline-label.tsx
import { Badge } from "@/components/ui/badge"export function CategoryBadge() {  return <Badge variant="outline">Documentation</Badge>}

API reference

PropTypeDefaultDescription
variant"default" | "secondary" | "destructive" | "outline" | "ghost" | "link""default"Selects the badge's visual style. The default variant is `default`.
classNamestring—Additional class names merged with the classes for the selected variant.
renderuseRender.ComponentProps<"span"> render prop—Base UI render customization prop forwarded to `useRender`; the default element is a `span`.
span propsuseRender.ComponentProps<"span">—Other props supported by the Base UI `useRender` component props for a span, such as standard span and global ARIA attributes, are forwarded to `useRender`.

Accessibility

  • The default element is a `span`, which does not provide an interactive role or keyboard behavior. Do not use a badge alone as an interactive control.
  • Use concise, meaningful text so the label makes sense to assistive technology and in context.
  • The component includes focus-visible outline styles, but a span is not normally focusable; use an appropriate interactive element when keyboard interaction is needed.
  • An `aria-invalid` attribute triggers destructive border styling, but does not itself provide error text or validation semantics.

Docs written by openai:gpt-6-luna from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Badge" component (neobrutalism/badge) from its shadcn registry.1. Install it with: npx shadcn@latest add https://neobrutalism.com/r/badge.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: variant, className, render, span props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Badge } from "@/components/ui/badge"export function BadgeExamples() {  return (    <div className="flex gap-2">      <Badge>New</Badge>      <Badge variant="secondary">In progress</Badge>      <Badge variant="destructive">Needs attention</Badge>    </div>  )}```

Files & dependencies

  • badge.tsx→ components/ui/badge.tsx
dependencies@base-ui/reactclass-variance-authority

Looks similar, elsewhere