Getting StartedInstall and bootstrap headless foundations 4
LayoutHeadless structural primitives for expandable and container patterns 6
OverlayHeadless modal and floating layer behavior 3
FeedbackHeadless notification and status communication patterns 5
FormHeadless input and selection contracts 17
UtilityReusable action, identity, and clipboard behavior 6
NavigationHeadless trails, trees, menus, and command surfaces 7

API reference

Headless Badge is a directive-only primitive. It attaches to your chosen host and generates a badge bubble element inside that host at runtime.

Directive selector

The primitive uses the attribute selector [tngBadge], so you can apply it to buttons, links, icons, tabs, or any other positioned host.

Badge host

html
<button type="button" [tngBadge]="5">Inbox</button>

Inputs and generated node

InputTypeDefaultNotes
tngBadgenumber | string | null | undefinednullPrimary count or text content.
tngBadgeDotbooleanfalseDot mode suppresses text content.
tngBadgeMaxnumber99Numeric values above max render as 99+.
tngBadgeHiddenbooleanfalseRemoves the generated badge node while true.
tngBadgePosition'top-end' | 'top-start' | 'bottom-end' | 'bottom-start''top-end'Placement corner used for badge anchoring.
tngBadgeSize, tngBadgeTone, tngBadgeVariantstring unions'md', 'danger', 'solid'Reflected as stable data attributes on the generated badge node.
tngBadgeOffsetX, tngBadgeOffsetYnumber | string | null | undefinednullExtra offset merged into the runtime transform.
tngBadgeClass, tngBadgeStylestring, Record<string, string | number>nullApplied directly to the generated bubble element.

The generated node is a span.tng-badge with aria-hidden="true", so the host should carry the meaningful accessible label.

Runtime positioning

The primitive tracks host and badge size with ResizeObserver when available, falling back to window resize. It also writes runtime metrics as CSS custom properties on the generated badge element.

Runtime CSS vars

css
.tng-badge {
  --tng-badge-anchor-width: 0px;
  --tng-badge-anchor-height: 0px;
  --tng-badge-self-width: 0px;
  --tng-badge-self-height: 0px;
}