Components
Badge
A small label used to highlight status, counts, or categorical information, with support for anchoring on top of other elements.
Badge
import { Badge } from "@/components/ui/badge";
export default function Particle() {
return <Badge>Badge</Badge>;
}
Installation
pnpm dlx shadcn@latest add @taut-ui/badge
Usage
import { Badge, BadgeAnchor } from "@/components/ui/badge"<Badge>Badge</Badge>Examples
Secondary
Secondary
import { Badge } from "@/components/ui/badge";
export default function Particle() {
return <Badge variant="secondary">Secondary</Badge>;
}
Outline
Outline
import { Badge } from "@/components/ui/badge";
export default function Particle() {
return <Badge variant="outline">Outline</Badge>;
}
Destructive
Destructive
import { Badge } from "@/components/ui/badge";
export default function Particle() {
return <Badge variant="destructive">Destructive</Badge>;
}
With Icon
Verified
import { CheckIcon } from "lucide-react";
import { Badge } from "@/components/ui/badge";
export default function Particle() {
return (
<Badge variant="success">
<CheckIcon />
Verified
</Badge>
);
}
Anchored Dot
import { BellIcon } from "lucide-react";
import { Badge, BadgeAnchor } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
export default function Particle() {
return (
<BadgeAnchor>
<Button aria-label="Notifications" size="icon" variant="outline">
<BellIcon />
</Button>
<Badge size="dot" variant="destructive" />
</BadgeAnchor>
);
}
Anchored Counter
12
import { InboxIcon } from "lucide-react";
import { Badge, BadgeAnchor } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
export default function Particle() {
return (
<BadgeAnchor>
<Button aria-label="Inbox" size="icon" variant="outline">
<InboxIcon />
</Button>
<Badge size="sm" variant="destructive">
12
</Badge>
</BadgeAnchor>
);
}
As Link
"use client";
import { ArrowUpRightIcon } from "lucide-react";
import Link from "next/link";
import { Badge } from "@/components/ui/badge";
export default function Particle() {
return (
<Badge
render={
<Link
href="#as-link"
onClick={(e) => e.preventDefault()}
prefetch={false}
/>
}
variant="secondary"
>
Release notes
<ArrowUpRightIcon />
</Badge>
);
}
API Reference
Badge
Renders a styled badge element. Supports polymorphic rendering via Base UI useRender.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "secondary" | "outline" | "destructive" | "error" | "info" | "success" | "warning" | "default" | Visual style variant |
size | "dot" | "sm" | "default" | "lg" | "default" | Size of the badge (dot renders a compact indicator with no text) |
render | React.ReactElement | ((props, state) => React.ReactElement) | - | Custom element to render (e.g. <a> or <button>) |
className | string | - | Additional CSS classes |
...props | React.ComponentProps<"span"> | - | All standard span attributes are supported |
BadgeAnchor
Wrapper that positions a child Badge relative to another element, such as an icon button or avatar.
| Prop | Type | Description |
|---|---|---|
render | React.ReactElement | ((props, state) => React.ReactElement) | Custom element to render as the wrapper |
className | string | Additional CSS classes |
...props | React.ComponentProps<"span"> | All standard span attributes are supported |