Headless Badge overview
tngBadge is a host directive that renders a generated badge bubble inside the host element. You own the host markup and surrounding layout, while the primitive manages the bubble node, placement, and runtime sizing sync.
Imports
Import the primitive directly when you want full control over the host element and its visual shell.
Headless import
ts
import { TngBadge } from '@tailng-ui/primitives';Basic usage
Bind numeric counts, strings, or dot mode directly on the host. The primitive inserts the badge bubble as an internal node and keeps it anchored to the host.
Minimal badge host
html
<button
type="button"
[tngBadge]="notifications()"
[tngBadgeMax]="99"
>
Inbox
</button>
Style variants
The same badge behavior rendered with owner-authored Plain CSS and Tailwind hosts.
Headless badge row (Plain CSS)
count: 12 | dot: on
Headless badge row (Tailwind CSS)
count: 4 | dot: off
Accessibility baseline
- The generated badge node is decorative by default and is marked with
aria-hidden="true". - Put the meaningful label on the host itself, for example
aria-label="Inbox notifications". - Use dot mode for status cues when you do not want the bubble to announce a numeric count.