badge

Inline status and metadata labels with semantic variants.

Use class="badge" on an inline element and set variant for appearance.

<span class="badge">Default</span>
<span variant="secondary" class="badge">Secondary</span>
<span variant="outline" class="badge">Outline</span>

For user-selected colors, use variant="custom" and set --badge-background. Browsers with contrast-color() choose a black or white foreground; set --badge-foreground when the application requires a specific contrast result.

<span variant="custom" class="badge" style="--badge-background: var(--cyan-9)">
  Custom
</span>

Example

View source
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>AngularCSS Badge</title>
    <link rel="stylesheet" href="../../css/preflight.css" />
    <link rel="stylesheet" href="../../css/angular.css" />
    <link rel="stylesheet" href="../example.css" />
    <script src="../../js/angular-ts.umd.js"></script>
    <script src="../../js/angular-css.umd.js"></script>
  </head>
  <body ng-app="angular.css" ng-cloak data-example="badge-demo">
    <div class="row visual-example">
      <span class="badge">Badge</span>
      <span variant="secondary" class="badge">Secondary</span>
      <span variant="destructive" class="badge">Destructive</span>
      <span variant="outline" class="badge">Outline</span>
      <span
        variant="custom"
        class="badge"
        style="--badge-background: var(--cyan-9)"
      >
        Custom
      </span>
    </div>
  </body>
</html>

Composition workflows

View source
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>AngularCSS Badge Workflows</title>
    <link rel="stylesheet" href="../../css/preflight.css" />
    <link rel="stylesheet" href="../../css/angular.css" />
    <link rel="stylesheet" href="../example.css" />
    <script src="../../js/angular-ts.umd.js"></script>
    <script src="../../js/angular-css.umd.js"></script>
  </head>
  <body
    ng-app="angular.css"
    ng-cloak
    data-example="badge-colors badge-icon badge-link badge-rtl badge-spinner badge-variants"
  >
    <main class="workflow-stack">
      <div class="workflow-row" aria-label="Badge variants">
        <span class="badge">Default</span>
        <span variant="secondary" class="badge">Secondary</span>
        <span variant="destructive" class="badge">Destructive</span>
        <span variant="outline" class="badge">Outline</span>
        <span variant="ghost" class="badge">Ghost</span>
      </div>

      <div class="workflow-row" aria-label="Badge custom colors">
        <span class="badge-color-blue badge">Blue</span>
        <span class="badge-color-green badge">Green</span>
        <span class="badge-color-sky badge">Sky</span>
        <span class="badge-color-purple badge">Purple</span>
        <span class="badge-color-red badge">Red</span>
      </div>

      <div class="workflow-row" aria-label="Badges with icons">
        <span variant="secondary" class="badge">
          <svg
            icon="inline-start"
            viewBox="0 0 24 24"
            fill="none"
            aria-hidden="true"
          >
            <path
              d="m9 12 2 2 4-4M12 3l2.2 1.5 2.7-.1.8 2.6 2.2 1.5-.9 2.5.9 2.5-2.2 1.5-.8 2.6-2.7-.1L12 21l-2.2-1.5-2.7.1-.8-2.6L4.1 15l.9-2.5-.9-2.5L6.3 7l.8-2.6 2.7.1L12 3Z"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
          </svg>
          Verified
        </span>
        <span variant="outline" class="badge">
          Bookmark
          <svg
            icon="inline-end"
            viewBox="0 0 24 24"
            fill="none"
            aria-hidden="true"
          >
            <path
              d="M6 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18l-6-4-6 4V4Z"
              stroke="currentColor"
              stroke-width="2"
              stroke-linejoin="round"
            />
          </svg>
        </span>
        <a href="#link" class="badge">
          Open Link
          <svg
            icon="inline-end"
            viewBox="0 0 24 24"
            fill="none"
            aria-hidden="true"
          >
            <path
              d="M7 17 17 7M7 7h10v10"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
          </svg>
        </a>
      </div>

      <div class="workflow-row" aria-label="Badges with loading status">
        <span variant="destructive" class="badge">
          <svg
            icon="inline-start"
            aria-hidden="true"
            viewBox="0 0 24 24"
            fill="none"
            class="spinner"
          >
            <path
              d="M21 12a9 9 0 1 1-6.22-8.56"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
            />
          </svg>
          Deleting
        </span>
        <span variant="secondary" class="badge">
          Generating
          <svg
            icon="inline-end"
            aria-hidden="true"
            viewBox="0 0 24 24"
            fill="none"
            class="spinner"
          >
            <path
              d="M21 12a9 9 0 1 1-6.22-8.56"
              stroke="currentColor"
              stroke-width="2"
              stroke-linecap="round"
            />
          </svg>
        </span>
      </div>

      <div class="workflow-row" dir="rtl" aria-label="RTL badges">
        <span class="badge">شارة</span>
        <span variant="secondary" class="badge">ثانوي</span>
        <span variant="destructive" class="badge">مدمر</span>
        <span variant="outline" class="badge">مخطط</span>
      </div>
    </main>
  </body>
</html>

Installation

Load the AngularCSS stylesheet. This entry needs no AngularCSS JavaScript or angular.css module dependency. Add AngularTS when using application bindings such as ng-model or ng-click. See Installation for the complete setup.

This entry uses native HTML and CSS. AngularCSS registers no runtime directive for it. Styled inline authored content.

Anatomy

Root styling selector

  • .badge

Semantic structure

Use semantic HTML with the root styling selector above. Native elements provide the structure; the stylesheet supplies presentation.

API

Attributes and state

AttributeAccessPurpose
iconAuthoredDirect icon position: inline-start or inline-end.
variantAuthoredPresentation: default, secondary, destructive, outline, ghost, or custom.

Attributes remain authored HTML, native state, or AngularTS inputs. AngularCSS does not write element state.

CSS custom properties

This styling hook does not define component-specific CSS custom properties.

DOM events

This component does not emit a component-specific custom event.

Native DOM events continue to work normally. AngularTS event directives such as ng-click and ng-keydown, plus the data-change model callback, remain application-owned.

Behavior

Styled inline authored content. AngularCSS supplies styling without a runtime directive. Native HTML owns platform behavior; AngularTS owns application values, commands, and authored state.

AngularCSS does not replace AngularTS interpolation, bindings, structural directives, form controllers, validation, or application state.

Accessibility

Use the appropriate live-region or status semantics for dynamic feedback. Decorative feedback must stay hidden from assistive technology.

Authored accessible names and relationships are preserved. Test the final composition with keyboard navigation and assistive technology because labels and content come from the application.

Customization

Target semantic elements, native state selectors, and component classes with ordinary CSS. Behavior and accessible state remain with native HTML and AngularTS; visual choices belong in the application stylesheet.

Read Customization for layer order, design tokens, state variants, and iframe demo isolation.