# Badge

A small, read-only label for status, category or freshness, such as Paid, Overdue or Beta. Use a chip when the user can remove the value.

- Package: [@vigdx/ui](https://www.npmjs.com/package/@vigdx/ui)
- Selectors: `vig-badge`
- Source: [libs/ui/src/lib/atoms/badge/badge.ts](https://github.com/bakyurekk/vigdx/blob/main/libs/ui/src/lib/atoms/badge/badge.ts)

```typescript title="Import"
import { Badge } from '@vigdx/ui/badge';
```

## Variants

`variant` picks a soft tone: `secondary` (default), `primary`, `accent`, `ghost` and the four status colors. Pick the tone by meaning, not decoration.

```typescript title="badge-variants.ts"
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Badge } from '@vigdx/ui/badge';

@Component({
  selector: 'app-badge-variants',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [Badge],
  template: `
    <div class="flex flex-wrap items-center gap-2">
      <vig-badge label="Draft" />
      <vig-badge label="New" variant="primary" />
      <vig-badge label="Beta" variant="accent" />
      <vig-badge label="Archived" variant="ghost" />
      <vig-badge label="Scheduled" variant="info" />
      <vig-badge label="Paid" variant="success" />
      <vig-badge label="Pending" variant="warning" />
      <vig-badge label="Overdue" variant="error" />
    </div>
  `,
})
export class BadgeVariantsDemo {}
```

## Status dot

`dot` prefixes the label with a small dot in the badge color, a common pattern for service or record status.

```typescript title="badge-dot.ts"
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Badge } from '@vigdx/ui/badge';

@Component({
  selector: 'app-badge-dot',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [Badge],
  template: `
    <div class="flex flex-wrap items-center gap-2">
      <vig-badge label="Operational" variant="success" [dot]="true" />
      <vig-badge label="Degraded" variant="warning" [dot]="true" />
      <vig-badge label="Outage" variant="error" [dot]="true" />
      <vig-badge label="Maintenance" variant="info" [dot]="true" />
    </div>
  `,
})
export class BadgeDotDemo {}
```

## Borderless

Set `bordered` to `false` for flat badges on busy surfaces such as dense tables.

```typescript title="badge-borderless.ts"
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Badge } from '@vigdx/ui/badge';

@Component({
  selector: 'app-badge-borderless',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [Badge],
  template: `
    <div class="flex flex-wrap items-center gap-2">
      <vig-badge label="Bordered" variant="primary" />
      <vig-badge label="Borderless" variant="primary" [bordered]="false" />
      <vig-badge label="Bordered" variant="success" />
      <vig-badge label="Borderless" variant="success" [bordered]="false" />
    </div>
  `,
})
export class BadgeBorderlessDemo {}
```

## Projected content

Without a `label` the badge renders its projected content, so it can hold inline markup. Badges sit inline with headings and text.

```typescript title="badge-in-context.ts"
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Badge } from '@vigdx/ui/badge';

@Component({
  selector: 'app-badge-in-context',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [Badge],
  template: `
    <div class="flex flex-col gap-4">
      <h3 class="flex items-center gap-2 text-h4 text-foreground">
        Usage reports <vig-badge label="Beta" variant="accent" />
      </h3>
      <p class="flex items-center gap-2 text-sm text-foreground">
        Invoice INV-2041
        <vig-badge variant="warning">Due in <strong>3</strong> days</vig-badge>
      </p>
    </div>
  `,
})
export class BadgeInContextDemo {}
```

## Styling hooks

Internal elements carry a stable `data-part` and the component's `data-scope`; both are public API, so removing one is a breaking change. Select a part by both, e.g. `[data-scope="badge"][data-part="root"] { … }`: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through `aria-*` and, where listed, a `data-state`; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other `data-*` attributes listed below (such as `data-opening` while an overlay animates) are API too. See [Customizing](https://vigdx.com/docs/theming.md#customizing).

Scope: `[data-scope="badge"]`

| Part | Element | data-state |
| --- | --- | --- |
| `root` | The visible badge. |   |
| `dot` | The status dot (`dot`). |   |

## Accessibility

- A badge is plain inline text with no role: screen readers read it as part of the surrounding content, so place it where that reading order makes sense.
- The status dot is decorative (`aria-hidden`); the label must carry the meaning on its own, never the color alone.
- If a badge changes while the user is on the page and the change matters, announce it through a live region (for example a toast or `role="status"` text).
- Every tone meets WCAG AA text contrast on its tinted fill in light and dark mode.

## API

### Badge

Selector: `vig-badge` · Kind: component

#### Inputs

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `bordered` | `boolean` | `true` | Draws the tinted outline; turn it off for flat chips on busy surfaces. |
| `dot` | `boolean` | `false` | Renders a small status dot in the current variant color. |
| `label` | `string \| undefined` | `undefined` | — |
| `variant` | `BadgeVariant` | `'secondary'` | — |
