Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Badge

    A small label for status, counts, and categories.

    Installation

    Source
    pnpm dlx zazz-ui add badge
    npx zazz-ui add badge
    yarn dlx zazz-ui add badge
    bunx zazz-ui add badge

    Also adds fields, which it depends on. Run zazz-ui init first if the project has no zazz/ folder yet.

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Paint the right theme (background, form controls, scrollbars) before CSS loads -->
    <meta name="color-scheme" content="light dark">
    <!-- Zazz styles: base layers, then fields, badge in cascade order -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_layers.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_variables.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_shadows.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_breakpoints.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_reset.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_typography.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_view-transitions.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/fields/fields.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/badge/badge.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-sm.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-md.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-lg.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-2xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-disabled.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-active.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-visible.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-within.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-hover.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-checked.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-current.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-open.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-stuck.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-starting.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-sm.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-md.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-lg.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-2xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-disabled.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-active.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-visible.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-within.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-hover.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-checked.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-current.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-open.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-stuck.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-starting.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-flow.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-grid.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-spacing.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-margin.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sizing.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-typography.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-color.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-effects.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-box.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-pseudo.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_defaults.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sr.css">
    <!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
    <script type="importmap">
    {
      "imports": {
        "signal-polyfill": "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js"
      },
      "integrity": {
        "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js": "sha384-0OqM7OXGT6Oz1z98u/geiFn/FUyz4iWexkXHCvbIGXRRDXl6bp6IKc0j78AQ6DEK"
      }
    }
    </script>
    <!-- Polyfill: Interest Invokers (interestfor) — native in Chromium only -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/invokers@2.2.2/dist/esm/production/interest.js" integrity="sha384-hR2BVNtsS7fIIMwOm+f7MY0JZfuByGhQQfevCBB6evFATKzBsTw0JzH/RxD94z2T" crossorigin="anonymous"></script>
    <!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/dialog-lifecycle.js"></script>
    <!-- Theme: apply the persisted (or preferred) scheme before first paint -->
    <script>
      (() => {
        try {
          // A stored choice pins the scheme with data-theme; with no choice the
          // page follows the system scheme.
          const storedTheme = localStorage.getItem("theme");
          if (storedTheme === "dark" || storedTheme === "light") {
            document.documentElement.dataset.theme = storedTheme;
          }
        } catch {
          /* no storage access: follow the system scheme */
        }
      })();
    </script>

    A <head> that loads the base layers and badge with its dependencies from jsDelivr, pinned to 0.14.2. To load the whole kit in two requests, see the CDN install.

    Examples

    Default

    <div
      style="
        --display: flex;
        --flex-wrap: wrap;
        --items: center;
        --gap: 4;
      "
    >
      <button type="button" data-ui="badge">Category</button>
      <button type="button" data-ui="badge" data-badge-variant="primary">New</button>
      <button type="button" data-ui="badge" data-badge-variant="muted">Draft</button>
      <button type="button" data-ui="badge" data-badge-variant="ghost">Inline</button>
      <button type="button" data-ui="badge" data-badge-variant="info">Update</button>
      <button type="button" data-ui="badge" data-badge-variant="success">Paid</button>
      <button type="button" data-ui="badge" data-badge-variant="warning">Pending</button>
      <button type="button" data-ui="badge" data-badge-variant="destructive">Overdue</button>
      <button type="button" data-ui="badge" data-badge-variant="link">Posts</button>
    </div>
    /**
     * badge.css: Badge ([data-ui~="badge"])
     *
     * @layer      variables, components
     * @requires   _layers.css, _variables.css, _reset.css, _properties.css (--_*-resolved, --_focus-shadow), fields.css (--ui-field-* border/ring)
     * @uses       color-mix(), oklch(from …): variant hover/active tints
     * @uses       text-box: vertical trim (patchy browser support)
     * @uses       --_touch-min (touch screens): an interactive badge keeps its size and extends an
     *             invisible ::after hit area to the touch floor
     * @uses       corner-shape — superellipse corners; unsupported browsers keep plain
     *             rounded corners
     * @tokens     --ui-badge-* (@layer variables; hooks are named after the utilities they back)
     * @consumedby combobox.css (selection tags)
     *
     * Every utility-backed declaration reads one chain, highest first:
     *   var(--_<utility>-resolved, var(--_badge-<utility>, var(--ui-badge-<utility>)))
     * States apply only to interactive badges (button, a[href]).
     *
     * States step one way and active goes further than hover. Unfilled surfaces (the
     * default, outline, ghost) gain the muted role; filled ones fade toward the page;
     * status surfaces darken. Button and badge resolve the same in every variant
     * (badge-button-parity.browser.test.ts).
     */
    
    @layer variables {
      :root {
        /* border + ring follow --ui-field-*; metrics stay independent (badges are smaller) */
        --ui-badge-ring-color: var(--ui-field-ring-color);
    
        --ui-badge-font-family: var(--font-family-body);
        --ui-badge-font-size: var(--font-size-xs);
        --ui-badge-font-weight: var(--font-weight-strong);
        --ui-badge-leading: 1;
    
        --ui-badge-bg: var(--color-background);
        --ui-badge-bg--hover: var(--color-muted);
        --ui-badge-bg--active: oklch(from var(--ui-badge-bg--hover) l c h / calc(alpha * 1.5));
    
        --ui-badge-text: var(--color-foreground);
        --ui-badge-text--hover: var(--color-foreground);
        --ui-badge-text--active: var(--color-foreground);
    
        --ui-badge-border-width: var(--ui-field-border-width);
        --ui-badge-border-style: var(--ui-field-border-style);
        --ui-badge-border-color: var(--ui-field-border-color);
        --ui-badge-border-color--hover: var(--ui-field-border-color);
        --ui-badge-border-color--active: var(--ui-field-border-color);
    
        /* dual-mode: a scale number or a length */
        --ui-badge-gap: var(--spacing);
        /* smaller than --ui-field-py: in a browser without text-box trim, the full line,
           this, and the border still fit the default height (to
           within a fraction of a pixel at the smallest fluid --spacing) */
        --ui-badge-py: calc(var(--spacing) * 0.75);
        --ui-badge-px: calc(var(--spacing) * 1.25);
        --ui-badge-h: calc(var(--spacing) * 5);
        --ui-badge-radius: var(--radius-sm);
        --ui-badge-corner-shape: var(--radius-corner-shape);
        --ui-badge-background-clip: border-box;
    
        --ui-badge-icon-size: calc(var(--spacing) * 3);
    
        /* never `none`: the focus ring layers into this box-shadow list */
        --ui-badge-shadow: 0 0 transparent;
      }
    }
    
    /* Variant privates: non-inheriting so a variant never cascades into a nested badge. */
    @property --_badge-ring-color {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-font-family {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-font-size {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-font-weight {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-leading {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-bg {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-bg--hover {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-bg--active {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-text {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-text--hover {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-text--active {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-width {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-style {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-color {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-color--hover {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-color--active {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-gap {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-py {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-px {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-h {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-radius {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-background-clip {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-icon-size {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-shadow {
      syntax: "*";
      inherits: false;
    }
    
    @layer ui.components {
      :where([data-ui~="badge"]) {
        font-family: var(
          --_font-family-resolved,
          var(--_badge-font-family, var(--ui-badge-font-family))
        );
        font-size: var(--_font-size-resolved, var(--_badge-font-size, var(--ui-badge-font-size)));
        font-weight: var(
          --_font-weight-resolved,
          var(--_badge-font-weight, var(--ui-badge-font-weight))
        );
        line-height: var(--_leading-resolved, var(--_badge-leading, var(--ui-badge-leading)));
    
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    
        --_gap-len: var(--_gap-resolved, var(--_badge-gap, var(--ui-badge-gap)));
        --_gap-num: var(--_gap-resolved, var(--_badge-gap, var(--ui-badge-gap)));
        gap: calc(var(--_gap-len) + var(--_gap-num) * var(--spacing));
    
        --_h-len: var(--_h-resolved, var(--_badge-h, var(--ui-badge-h)));
        --_h-num: var(--_h-resolved, var(--_badge-h, var(--ui-badge-h)));
        /* --h is a floor: the label plus --ui-badge-py on each side can outgrow it at a
           small --spacing. fit-content, not auto, so a flex row never stretches it. */
        block-size: fit-content;
        min-block-size: calc(var(--_h-len) + var(--_h-num) * var(--spacing));
        min-inline-size: max-content;
    
        --_py-len: var(--_py-resolved, var(--_badge-py, var(--ui-badge-py)));
        --_py-num: var(--_py-resolved, var(--_badge-py, var(--ui-badge-py)));
        padding-block: calc(var(--_py-len) + var(--_py-num) * var(--spacing));
    
        --_px-len: var(--_px-resolved, var(--_badge-px, var(--ui-badge-px)));
        --_px-num: var(--_px-resolved, var(--_badge-px, var(--ui-badge-px)));
        padding-inline: calc(var(--_px-len) + var(--_px-num) * var(--spacing));
    
        border-width: var(
          --_border-width-resolved,
          var(--_badge-border-width, var(--ui-badge-border-width))
        );
        border-style: var(
          --_border-style-resolved,
          var(--_badge-border-style, var(--ui-badge-border-style))
        );
        border-color: var(
          --_border-color-resolved,
          var(--_badge-border-color, var(--ui-badge-border-color))
        );
        --_radius-len: var(--_radius-resolved, var(--_badge-radius, var(--ui-badge-radius)));
        --_radius-num: var(--_radius-resolved, var(--_badge-radius, var(--ui-badge-radius)));
        border-radius: calc(
          var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
        );
        corner-shape: var(--_corner-shape-resolved, var(--ui-badge-corner-shape));
    
        color: var(--_text-resolved, var(--_badge-text, var(--ui-badge-text)));
        background-color: var(--_bg-resolved, var(--_badge-bg, var(--ui-badge-bg)));
        background-clip: var(
          --_bg-clip-resolved,
          var(--_badge-background-clip, var(--ui-badge-background-clip))
        );
        white-space-collapse: collapse;
    
        /* The ring is published to --_focus-shadow so the utilities layer's
           box-shadow emission keeps it above a --shadow or --ring utility; the ring
           widths grow from 0 on :focus-visible so the ring eases in. */
        --_ring-offset-width: 0px;
        --_ring-width: 0px;
        --_focus-in: max(0, -1 * sign(var(--_focus-ring-w, 1px)));
        --_ring-fill: color-mix(
          in oklch,
          var(--_ring-color-resolved, var(--_badge-ring-color, var(--ui-badge-ring-color)))
            var(--ring-opacity),
          transparent
        );
        --_focus-shadow:
          0 0 0 calc(var(--_ring-offset-width) * (1 - var(--_focus-in))) var(--ring-offset-shadow-color),
          0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * (1 - var(--_focus-in)))
            var(--_ring-fill, var(--ring-shadow-color)),
          inset 0 0 0 calc(var(--_ring-offset-width) * var(--_focus-in)) var(--ring-offset-shadow-color),
          inset 0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * var(--_focus-in))
            var(--_ring-fill, var(--ring-shadow-color));
        box-shadow:
          var(--_focus-shadow, 0 0 #0000),
          var(--_shadow-resolved, var(--_badge-shadow, var(--ui-badge-shadow)));
    
        cursor: default;
        text-decoration: none;
    
        /* transparent twin of the ring for forced-colors / high-contrast modes */
        outline: abs(var(--_focus-ring-w, var(--outline-width))) var(--outline-style) transparent;
        outline-offset: calc(
          var(--outline-offset) - var(--_focus-in) *
            (2 * var(--outline-offset) + abs(var(--_focus-ring-w, var(--outline-width))))
        );
    
        transition: var(--default-transition);
    
        user-select: none;
        text-box: trim-both ex alphabetic;
      }
    
      a[href] :where([data-ui~="badge"]):not(:disabled, [aria-disabled="true"]),
      a[href]:where([data-ui~="badge"]):not(:disabled, [aria-disabled="true"]) {
        cursor: pointer;
      }
    
      /* ===========================================================================
      BADGE STATES — interactive badges only (button, a[href])
      =========================================================================== */
    
      /* touch: the badge keeps its box; a transparent ::after centred on it is at least
         --_touch-min square (it collapses to the box on a mouse) */
      :where([data-ui~="badge"]):is(button, a[href]) {
        position: relative;
      }
    
      :where([data-ui~="badge"]:is(button, a[href]))::after {
        content: "";
        position: absolute;
        inset: min(0px, calc((100% - var(--_touch-min)) / 2));
      }
    
      @media (hover: hover) {
        :where([data-ui~="badge"]):is(button, a[href]):hover:not(:disabled, [aria-disabled="true"]) {
          color: var(--_text-resolved, var(--_badge-text--hover, var(--ui-badge-text--hover)));
          background-color: var(--_bg-resolved, var(--_badge-bg--hover, var(--ui-badge-bg--hover)));
          border-color: var(
            --_border-color-resolved,
            var(--_badge-border-color--hover, var(--ui-badge-border-color--hover))
          );
        }
      }
    
      :where([data-ui~="badge"]):is(button, a[href]):active:not(:disabled, [aria-disabled="true"]) {
        color: var(--_text-resolved, var(--_badge-text--active, var(--ui-badge-text--active)));
        background-color: var(--_bg-resolved, var(--_badge-bg--active, var(--ui-badge-bg--active)));
        border-color: var(
          --_border-color-resolved,
          var(--_badge-border-color--active, var(--ui-badge-border-color--active))
        );
      }
    
      :where([data-ui~="badge"]):is(button, a[href]):focus-visible:not(
          :disabled,
          [aria-disabled="true"]
        ) {
        --_ring-offset-width: var(--ring-offset-width);
        --_ring-width: abs(var(--_focus-ring-w, var(--ring-width)));
    
        outline-color: transparent;
      }
    
      /* before the variants at the same specificity: a disabled primary keeps its color */
      :where([data-ui~="badge"]:is(:disabled, [aria-disabled="true"])) {
        --_badge-text: var(--color-muted-foreground);
        --_badge-bg: var(--color-muted);
        --_badge-shadow: 0 0 transparent;
        --decoration-line: none;
    
        cursor: default;
        opacity: 0.6;
        outline: none;
      }
    
      :where([data-ui~="badge"]):is(button, a[href])[aria-busy="true"] {
        cursor: progress;
      }
    
      /* ===========================================================================
      BADGE ICONS
      =========================================================================== */
    
      :where([data-ui~="badge"]) > svg {
        inline-size: var(--ui-badge-icon-size);
        block-size: var(--ui-badge-icon-size);
        pointer-events: none;
        justify-content: center;
        align-items: center;
        display: flex;
        padding: 0;
      }
    
      /* ===========================================================================
      BADGE VARIANTS — data-badge-variant writes the privates
      =========================================================================== */
    
      :where([data-ui~="badge"][data-badge-variant="outline"]) {
        --_badge-bg: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="primary"]) {
        --_badge-bg: var(--color-primary);
        --_badge-bg--hover: light-dark(
          oklch(from var(--color-primary) calc(l + (1 - l) * 0.2) c h),
          oklch(from var(--color-primary) calc(l * 0.8) c h)
        );
        --_badge-bg--active: light-dark(
          oklch(from var(--color-primary) calc(l + (1 - l) * 0.3) c h),
          oklch(from var(--color-primary) calc(l * 0.7) c h)
        );
    
        --_badge-text: var(--color-primary-foreground);
        --_badge-text--hover: var(--color-primary-foreground);
        --_badge-text--active: var(--color-primary-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="secondary"]) {
        --_badge-bg: var(--color-secondary);
        --_badge-bg--hover: light-dark(
          oklch(from var(--color-secondary) calc(l + (1 - l) * 0.2) c h),
          oklch(from var(--color-secondary) calc(l * 0.8) c h)
        );
        --_badge-bg--active: light-dark(
          oklch(from var(--color-secondary) calc(l + (1 - l) * 0.3) c h),
          oklch(from var(--color-secondary) calc(l * 0.7) c h)
        );
    
        --_badge-text: var(--color-secondary-foreground);
        --_badge-text--hover: var(--color-secondary-foreground);
        --_badge-text--active: var(--color-secondary-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="tertiary"]) {
        --_badge-bg: var(--color-tertiary);
        --_badge-bg--hover: light-dark(
          oklch(from var(--color-tertiary) calc(l + (1 - l) * 0.2) c h),
          oklch(from var(--color-tertiary) calc(l * 0.8) c h)
        );
        --_badge-bg--active: light-dark(
          oklch(from var(--color-tertiary) calc(l + (1 - l) * 0.3) c h),
          oklch(from var(--color-tertiary) calc(l * 0.7) c h)
        );
    
        --_badge-text: var(--color-tertiary-foreground);
        --_badge-text--hover: var(--color-tertiary-foreground);
        --_badge-text--active: var(--color-tertiary-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="muted"]) {
        /* the translucent muted role: fades toward the surface beneath */
        --_badge-bg: var(--color-muted);
        --_badge-bg--hover: oklch(from var(--_badge-bg) l c h / calc(alpha * 0.66));
        --_badge-bg--active: oklch(from var(--_badge-bg) l c h / calc(alpha * 0.33));
    
        --_badge-text: var(--color-foreground);
        --_badge-text--hover: var(--color-foreground);
        --_badge-text--active: var(--color-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="ghost"]) {
        --_badge-bg: transparent;
        /* the translucent muted role: shows the surface beneath and follows a retheme */
        --_badge-bg--hover: var(--color-muted);
        --_badge-bg--active: oklch(from var(--_badge-bg--hover) l c h / calc(alpha * 1.5));
    
        --_badge-text: var(--color-foreground);
        --_badge-text--hover: var(--color-foreground);
        --_badge-text--active: var(--color-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      /* Status variants (info, success, warning, destructive) pair the role's
         surface with its -foreground. No border. One rule derives the states from
         the surface; each variant names only its role. status-contrast.browser.test.ts
         checks 4.5:1 at rest, hover, and active. */
      :where(
        [data-ui~="badge"]:is(
          [data-badge-variant="info"],
          [data-badge-variant="success"],
          [data-badge-variant="warning"],
          [data-badge-variant="destructive"]
        )
      ) {
        --_badge-bg--hover: oklch(from var(--_badge-bg) calc(l - 0.025) c h);
        --_badge-bg--active: oklch(from var(--_badge-bg) calc(l - 0.05) c h);
    
        --_badge-text--hover: var(--_badge-text);
        --_badge-text--active: var(--_badge-text);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="info"]) {
        --_badge-ring-color: var(--color-info-foreground);
        --_badge-bg: var(--color-info);
        --_badge-text: var(--color-info-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="success"]) {
        --_badge-ring-color: var(--color-success-foreground);
        --_badge-bg: var(--color-success);
        --_badge-text: var(--color-success-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="warning"]) {
        --_badge-ring-color: var(--color-warning-foreground);
        --_badge-bg: var(--color-warning);
        --_badge-text: var(--color-warning-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="destructive"]) {
        --_badge-ring-color: var(--color-destructive-foreground);
        --_badge-bg: var(--color-destructive);
        --_badge-text: var(--color-destructive-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="link"]) {
        --_badge-bg: transparent;
        --_badge-bg--hover: transparent;
        --_badge-bg--active: transparent;
    
        --_badge-text: var(--color-foreground);
        --_badge-text--hover: var(--color-muted-foreground);
        --_badge-text--active: var(--color-muted-foreground);
    
        --_badge-border-style: none;
    
        --_badge-px: 0;
        --_badge-radius: 0;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      /* ===========================================================================
      BADGE SIZES — data-badge-size
      =========================================================================== */
    
      :where([data-ui~="badge"][data-badge-size="icon"]) {
        inline-size: calc(var(--_h-len) + var(--_h-num) * var(--spacing));
        padding: 0;
        aspect-ratio: 1 / 1;
      }
    }

    Icon

    <button type="button" data-ui="badge" data-badge-size="icon" aria-label="Icon badge default">
      <svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <circle cx="128" cy="128" r="12" />
        <circle cx="196" cy="128" r="12" />
        <circle cx="60" cy="128" r="12" />
      </svg>
    </button>
    <button
      type="button"
      data-ui="badge"
      data-badge-size="icon"
      data-badge-variant="primary"
      aria-label="Icon badge primary"
    >
      <svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <circle cx="128" cy="128" r="12" />
        <circle cx="196" cy="128" r="12" />
        <circle cx="60" cy="128" r="12" />
      </svg>
    </button>
    <button
      type="button"
      data-ui="badge"
      data-badge-size="icon"
      data-badge-variant="muted"
      aria-label="Icon badge muted"
    >
      <svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <circle cx="128" cy="128" r="12" />
        <circle cx="196" cy="128" r="12" />
        <circle cx="60" cy="128" r="12" />
      </svg>
    </button>
    <button
      type="button"
      data-ui="badge"
      data-badge-size="icon"
      data-badge-variant="ghost"
      aria-label="Icon badge ghost"
    >
      <svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <circle cx="128" cy="128" r="12" />
        <circle cx="196" cy="128" r="12" />
        <circle cx="60" cy="128" r="12" />
      </svg>
    </button>
    /**
     * badge.css: Badge ([data-ui~="badge"])
     *
     * @layer      variables, components
     * @requires   _layers.css, _variables.css, _reset.css, _properties.css (--_*-resolved, --_focus-shadow), fields.css (--ui-field-* border/ring)
     * @uses       color-mix(), oklch(from …): variant hover/active tints
     * @uses       text-box: vertical trim (patchy browser support)
     * @uses       --_touch-min (touch screens): an interactive badge keeps its size and extends an
     *             invisible ::after hit area to the touch floor
     * @uses       corner-shape — superellipse corners; unsupported browsers keep plain
     *             rounded corners
     * @tokens     --ui-badge-* (@layer variables; hooks are named after the utilities they back)
     * @consumedby combobox.css (selection tags)
     *
     * Every utility-backed declaration reads one chain, highest first:
     *   var(--_<utility>-resolved, var(--_badge-<utility>, var(--ui-badge-<utility>)))
     * States apply only to interactive badges (button, a[href]).
     *
     * States step one way and active goes further than hover. Unfilled surfaces (the
     * default, outline, ghost) gain the muted role; filled ones fade toward the page;
     * status surfaces darken. Button and badge resolve the same in every variant
     * (badge-button-parity.browser.test.ts).
     */
    
    @layer variables {
      :root {
        /* border + ring follow --ui-field-*; metrics stay independent (badges are smaller) */
        --ui-badge-ring-color: var(--ui-field-ring-color);
    
        --ui-badge-font-family: var(--font-family-body);
        --ui-badge-font-size: var(--font-size-xs);
        --ui-badge-font-weight: var(--font-weight-strong);
        --ui-badge-leading: 1;
    
        --ui-badge-bg: var(--color-background);
        --ui-badge-bg--hover: var(--color-muted);
        --ui-badge-bg--active: oklch(from var(--ui-badge-bg--hover) l c h / calc(alpha * 1.5));
    
        --ui-badge-text: var(--color-foreground);
        --ui-badge-text--hover: var(--color-foreground);
        --ui-badge-text--active: var(--color-foreground);
    
        --ui-badge-border-width: var(--ui-field-border-width);
        --ui-badge-border-style: var(--ui-field-border-style);
        --ui-badge-border-color: var(--ui-field-border-color);
        --ui-badge-border-color--hover: var(--ui-field-border-color);
        --ui-badge-border-color--active: var(--ui-field-border-color);
    
        /* dual-mode: a scale number or a length */
        --ui-badge-gap: var(--spacing);
        /* smaller than --ui-field-py: in a browser without text-box trim, the full line,
           this, and the border still fit the default height (to
           within a fraction of a pixel at the smallest fluid --spacing) */
        --ui-badge-py: calc(var(--spacing) * 0.75);
        --ui-badge-px: calc(var(--spacing) * 1.25);
        --ui-badge-h: calc(var(--spacing) * 5);
        --ui-badge-radius: var(--radius-sm);
        --ui-badge-corner-shape: var(--radius-corner-shape);
        --ui-badge-background-clip: border-box;
    
        --ui-badge-icon-size: calc(var(--spacing) * 3);
    
        /* never `none`: the focus ring layers into this box-shadow list */
        --ui-badge-shadow: 0 0 transparent;
      }
    }
    
    /* Variant privates: non-inheriting so a variant never cascades into a nested badge. */
    @property --_badge-ring-color {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-font-family {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-font-size {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-font-weight {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-leading {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-bg {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-bg--hover {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-bg--active {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-text {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-text--hover {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-text--active {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-width {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-style {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-color {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-color--hover {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-border-color--active {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-gap {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-py {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-px {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-h {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-radius {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-background-clip {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-icon-size {
      syntax: "*";
      inherits: false;
    }
    
    @property --_badge-shadow {
      syntax: "*";
      inherits: false;
    }
    
    @layer ui.components {
      :where([data-ui~="badge"]) {
        font-family: var(
          --_font-family-resolved,
          var(--_badge-font-family, var(--ui-badge-font-family))
        );
        font-size: var(--_font-size-resolved, var(--_badge-font-size, var(--ui-badge-font-size)));
        font-weight: var(
          --_font-weight-resolved,
          var(--_badge-font-weight, var(--ui-badge-font-weight))
        );
        line-height: var(--_leading-resolved, var(--_badge-leading, var(--ui-badge-leading)));
    
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    
        --_gap-len: var(--_gap-resolved, var(--_badge-gap, var(--ui-badge-gap)));
        --_gap-num: var(--_gap-resolved, var(--_badge-gap, var(--ui-badge-gap)));
        gap: calc(var(--_gap-len) + var(--_gap-num) * var(--spacing));
    
        --_h-len: var(--_h-resolved, var(--_badge-h, var(--ui-badge-h)));
        --_h-num: var(--_h-resolved, var(--_badge-h, var(--ui-badge-h)));
        /* --h is a floor: the label plus --ui-badge-py on each side can outgrow it at a
           small --spacing. fit-content, not auto, so a flex row never stretches it. */
        block-size: fit-content;
        min-block-size: calc(var(--_h-len) + var(--_h-num) * var(--spacing));
        min-inline-size: max-content;
    
        --_py-len: var(--_py-resolved, var(--_badge-py, var(--ui-badge-py)));
        --_py-num: var(--_py-resolved, var(--_badge-py, var(--ui-badge-py)));
        padding-block: calc(var(--_py-len) + var(--_py-num) * var(--spacing));
    
        --_px-len: var(--_px-resolved, var(--_badge-px, var(--ui-badge-px)));
        --_px-num: var(--_px-resolved, var(--_badge-px, var(--ui-badge-px)));
        padding-inline: calc(var(--_px-len) + var(--_px-num) * var(--spacing));
    
        border-width: var(
          --_border-width-resolved,
          var(--_badge-border-width, var(--ui-badge-border-width))
        );
        border-style: var(
          --_border-style-resolved,
          var(--_badge-border-style, var(--ui-badge-border-style))
        );
        border-color: var(
          --_border-color-resolved,
          var(--_badge-border-color, var(--ui-badge-border-color))
        );
        --_radius-len: var(--_radius-resolved, var(--_badge-radius, var(--ui-badge-radius)));
        --_radius-num: var(--_radius-resolved, var(--_badge-radius, var(--ui-badge-radius)));
        border-radius: calc(
          var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
        );
        corner-shape: var(--_corner-shape-resolved, var(--ui-badge-corner-shape));
    
        color: var(--_text-resolved, var(--_badge-text, var(--ui-badge-text)));
        background-color: var(--_bg-resolved, var(--_badge-bg, var(--ui-badge-bg)));
        background-clip: var(
          --_bg-clip-resolved,
          var(--_badge-background-clip, var(--ui-badge-background-clip))
        );
        white-space-collapse: collapse;
    
        /* The ring is published to --_focus-shadow so the utilities layer's
           box-shadow emission keeps it above a --shadow or --ring utility; the ring
           widths grow from 0 on :focus-visible so the ring eases in. */
        --_ring-offset-width: 0px;
        --_ring-width: 0px;
        --_focus-in: max(0, -1 * sign(var(--_focus-ring-w, 1px)));
        --_ring-fill: color-mix(
          in oklch,
          var(--_ring-color-resolved, var(--_badge-ring-color, var(--ui-badge-ring-color)))
            var(--ring-opacity),
          transparent
        );
        --_focus-shadow:
          0 0 0 calc(var(--_ring-offset-width) * (1 - var(--_focus-in))) var(--ring-offset-shadow-color),
          0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * (1 - var(--_focus-in)))
            var(--_ring-fill, var(--ring-shadow-color)),
          inset 0 0 0 calc(var(--_ring-offset-width) * var(--_focus-in)) var(--ring-offset-shadow-color),
          inset 0 0 0 calc((var(--_ring-offset-width) + var(--_ring-width)) * var(--_focus-in))
            var(--_ring-fill, var(--ring-shadow-color));
        box-shadow:
          var(--_focus-shadow, 0 0 #0000),
          var(--_shadow-resolved, var(--_badge-shadow, var(--ui-badge-shadow)));
    
        cursor: default;
        text-decoration: none;
    
        /* transparent twin of the ring for forced-colors / high-contrast modes */
        outline: abs(var(--_focus-ring-w, var(--outline-width))) var(--outline-style) transparent;
        outline-offset: calc(
          var(--outline-offset) - var(--_focus-in) *
            (2 * var(--outline-offset) + abs(var(--_focus-ring-w, var(--outline-width))))
        );
    
        transition: var(--default-transition);
    
        user-select: none;
        text-box: trim-both ex alphabetic;
      }
    
      a[href] :where([data-ui~="badge"]):not(:disabled, [aria-disabled="true"]),
      a[href]:where([data-ui~="badge"]):not(:disabled, [aria-disabled="true"]) {
        cursor: pointer;
      }
    
      /* ===========================================================================
      BADGE STATES — interactive badges only (button, a[href])
      =========================================================================== */
    
      /* touch: the badge keeps its box; a transparent ::after centred on it is at least
         --_touch-min square (it collapses to the box on a mouse) */
      :where([data-ui~="badge"]):is(button, a[href]) {
        position: relative;
      }
    
      :where([data-ui~="badge"]:is(button, a[href]))::after {
        content: "";
        position: absolute;
        inset: min(0px, calc((100% - var(--_touch-min)) / 2));
      }
    
      @media (hover: hover) {
        :where([data-ui~="badge"]):is(button, a[href]):hover:not(:disabled, [aria-disabled="true"]) {
          color: var(--_text-resolved, var(--_badge-text--hover, var(--ui-badge-text--hover)));
          background-color: var(--_bg-resolved, var(--_badge-bg--hover, var(--ui-badge-bg--hover)));
          border-color: var(
            --_border-color-resolved,
            var(--_badge-border-color--hover, var(--ui-badge-border-color--hover))
          );
        }
      }
    
      :where([data-ui~="badge"]):is(button, a[href]):active:not(:disabled, [aria-disabled="true"]) {
        color: var(--_text-resolved, var(--_badge-text--active, var(--ui-badge-text--active)));
        background-color: var(--_bg-resolved, var(--_badge-bg--active, var(--ui-badge-bg--active)));
        border-color: var(
          --_border-color-resolved,
          var(--_badge-border-color--active, var(--ui-badge-border-color--active))
        );
      }
    
      :where([data-ui~="badge"]):is(button, a[href]):focus-visible:not(
          :disabled,
          [aria-disabled="true"]
        ) {
        --_ring-offset-width: var(--ring-offset-width);
        --_ring-width: abs(var(--_focus-ring-w, var(--ring-width)));
    
        outline-color: transparent;
      }
    
      /* before the variants at the same specificity: a disabled primary keeps its color */
      :where([data-ui~="badge"]:is(:disabled, [aria-disabled="true"])) {
        --_badge-text: var(--color-muted-foreground);
        --_badge-bg: var(--color-muted);
        --_badge-shadow: 0 0 transparent;
        --decoration-line: none;
    
        cursor: default;
        opacity: 0.6;
        outline: none;
      }
    
      :where([data-ui~="badge"]):is(button, a[href])[aria-busy="true"] {
        cursor: progress;
      }
    
      /* ===========================================================================
      BADGE ICONS
      =========================================================================== */
    
      :where([data-ui~="badge"]) > svg {
        inline-size: var(--ui-badge-icon-size);
        block-size: var(--ui-badge-icon-size);
        pointer-events: none;
        justify-content: center;
        align-items: center;
        display: flex;
        padding: 0;
      }
    
      /* ===========================================================================
      BADGE VARIANTS — data-badge-variant writes the privates
      =========================================================================== */
    
      :where([data-ui~="badge"][data-badge-variant="outline"]) {
        --_badge-bg: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="primary"]) {
        --_badge-bg: var(--color-primary);
        --_badge-bg--hover: light-dark(
          oklch(from var(--color-primary) calc(l + (1 - l) * 0.2) c h),
          oklch(from var(--color-primary) calc(l * 0.8) c h)
        );
        --_badge-bg--active: light-dark(
          oklch(from var(--color-primary) calc(l + (1 - l) * 0.3) c h),
          oklch(from var(--color-primary) calc(l * 0.7) c h)
        );
    
        --_badge-text: var(--color-primary-foreground);
        --_badge-text--hover: var(--color-primary-foreground);
        --_badge-text--active: var(--color-primary-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="secondary"]) {
        --_badge-bg: var(--color-secondary);
        --_badge-bg--hover: light-dark(
          oklch(from var(--color-secondary) calc(l + (1 - l) * 0.2) c h),
          oklch(from var(--color-secondary) calc(l * 0.8) c h)
        );
        --_badge-bg--active: light-dark(
          oklch(from var(--color-secondary) calc(l + (1 - l) * 0.3) c h),
          oklch(from var(--color-secondary) calc(l * 0.7) c h)
        );
    
        --_badge-text: var(--color-secondary-foreground);
        --_badge-text--hover: var(--color-secondary-foreground);
        --_badge-text--active: var(--color-secondary-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="tertiary"]) {
        --_badge-bg: var(--color-tertiary);
        --_badge-bg--hover: light-dark(
          oklch(from var(--color-tertiary) calc(l + (1 - l) * 0.2) c h),
          oklch(from var(--color-tertiary) calc(l * 0.8) c h)
        );
        --_badge-bg--active: light-dark(
          oklch(from var(--color-tertiary) calc(l + (1 - l) * 0.3) c h),
          oklch(from var(--color-tertiary) calc(l * 0.7) c h)
        );
    
        --_badge-text: var(--color-tertiary-foreground);
        --_badge-text--hover: var(--color-tertiary-foreground);
        --_badge-text--active: var(--color-tertiary-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="muted"]) {
        /* the translucent muted role: fades toward the surface beneath */
        --_badge-bg: var(--color-muted);
        --_badge-bg--hover: oklch(from var(--_badge-bg) l c h / calc(alpha * 0.66));
        --_badge-bg--active: oklch(from var(--_badge-bg) l c h / calc(alpha * 0.33));
    
        --_badge-text: var(--color-foreground);
        --_badge-text--hover: var(--color-foreground);
        --_badge-text--active: var(--color-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="ghost"]) {
        --_badge-bg: transparent;
        /* the translucent muted role: shows the surface beneath and follows a retheme */
        --_badge-bg--hover: var(--color-muted);
        --_badge-bg--active: oklch(from var(--_badge-bg--hover) l c h / calc(alpha * 1.5));
    
        --_badge-text: var(--color-foreground);
        --_badge-text--hover: var(--color-foreground);
        --_badge-text--active: var(--color-foreground);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      /* Status variants (info, success, warning, destructive) pair the role's
         surface with its -foreground. No border. One rule derives the states from
         the surface; each variant names only its role. status-contrast.browser.test.ts
         checks 4.5:1 at rest, hover, and active. */
      :where(
        [data-ui~="badge"]:is(
          [data-badge-variant="info"],
          [data-badge-variant="success"],
          [data-badge-variant="warning"],
          [data-badge-variant="destructive"]
        )
      ) {
        --_badge-bg--hover: oklch(from var(--_badge-bg) calc(l - 0.025) c h);
        --_badge-bg--active: oklch(from var(--_badge-bg) calc(l - 0.05) c h);
    
        --_badge-text--hover: var(--_badge-text);
        --_badge-text--active: var(--_badge-text);
    
        --_badge-border-color: transparent;
        --_badge-border-color--hover: transparent;
        --_badge-border-color--active: transparent;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      :where([data-ui~="badge"][data-badge-variant="info"]) {
        --_badge-ring-color: var(--color-info-foreground);
        --_badge-bg: var(--color-info);
        --_badge-text: var(--color-info-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="success"]) {
        --_badge-ring-color: var(--color-success-foreground);
        --_badge-bg: var(--color-success);
        --_badge-text: var(--color-success-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="warning"]) {
        --_badge-ring-color: var(--color-warning-foreground);
        --_badge-bg: var(--color-warning);
        --_badge-text: var(--color-warning-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="destructive"]) {
        --_badge-ring-color: var(--color-destructive-foreground);
        --_badge-bg: var(--color-destructive);
        --_badge-text: var(--color-destructive-foreground);
      }
    
      :where([data-ui~="badge"][data-badge-variant="link"]) {
        --_badge-bg: transparent;
        --_badge-bg--hover: transparent;
        --_badge-bg--active: transparent;
    
        --_badge-text: var(--color-foreground);
        --_badge-text--hover: var(--color-muted-foreground);
        --_badge-text--active: var(--color-muted-foreground);
    
        --_badge-border-style: none;
    
        --_badge-px: 0;
        --_badge-radius: 0;
    
        --_badge-shadow: 0 0 transparent;
      }
    
      /* ===========================================================================
      BADGE SIZES — data-badge-size
      =========================================================================== */
    
      :where([data-ui~="badge"][data-badge-size="icon"]) {
        inline-size: calc(var(--_h-len) + var(--_h-num) * var(--spacing));
        padding: 0;
        aspect-ratio: 1 / 1;
      }
    }

    Attributes

    badge attributes
    AttributeKindValuesNotes
    data-ui="badge"Identityfree valueIdentity token in data-ui.
    data-badge-sizePreseticonPreset: a named bundle of values.
    data-badge-variantPresetdestructive ghost info link muted outline primary secondary success tertiary warningPreset: a named bundle of values.

    Requires: fields.

    Hooks

    Set a hook on :root, on a subtree, or inline on one element. A state hook (--…--hover) themes that state only; the primitive keeps its other states.

    badge hooks
    HookDefaultState
    --ui-badge-background-clipborder-box—
    --ui-badge-bgvar(--color-background)—
    --ui-badge-bg--activeoklch(from var(--ui-badge-bg--hover) l c h / calc(alpha * 1.5))active
    --ui-badge-bg--hovervar(--color-muted)hover
    --ui-badge-border-colorvar(--ui-field-border-color)—
    --ui-badge-border-color--activevar(--ui-field-border-color)active
    --ui-badge-border-color--hovervar(--ui-field-border-color)hover
    --ui-badge-border-stylevar(--ui-field-border-style)—
    --ui-badge-border-widthvar(--ui-field-border-width)—
    --ui-badge-corner-shapevar(--radius-corner-shape)—
    --ui-badge-font-familyvar(--font-family-body)—
    --ui-badge-font-sizevar(--font-size-xs)—
    --ui-badge-font-weightvar(--font-weight-strong)—
    --ui-badge-gapvar(--spacing)—
    --ui-badge-hcalc(var(--spacing) * 5)—
    --ui-badge-icon-sizecalc(var(--spacing) * 3)—
    --ui-badge-leading1—
    --ui-badge-pxcalc(var(--spacing) * 1.25)—
    --ui-badge-pycalc(var(--spacing) * 0.75)—
    --ui-badge-radiusvar(--radius-sm)—
    --ui-badge-ring-colorvar(--ui-field-ring-color)—
    --ui-badge-shadow0 0 transparent—
    --ui-badge-textvar(--color-foreground)—
    --ui-badge-text--activevar(--color-foreground)active
    --ui-badge-text--hovervar(--color-foreground)hover

    API