Docs

Main site

Installation Browser support Extend config MCP server
Validation Page speed testing Responsive design
Accordion Aspect Ratio Avatar Badge Banner Bento Grid Blockquote Breadcrumbs Button Callout Card Drawer Dropdown Link Modal Navbar Navblock Pagination Popover Progress Separator Tabs Timeline Toast Tooltip
Checkbox Datepicker File upload Form field Input Label OTP Radio Range Select Textarea Toggle
Header Footer
Accordion Auth Checkbox & Radio Content Drawers Features Modals Statistics & Metrics Teams Dropdowns
Address Contact number Currency symbol Date Emirates ID Name
Close
Home Documentation Components Badge

Badge

Badges let users label, classify, or count items at a glance. A Badge is a small inline element used to communicate status, mark counts, or tag content with metadata. The badge component renders a real native "span" internally and exposes a rich set of properties.

Status Display
Status
Active
Introduced
4.0.x
View source code

Anatomy

The aegov-badge component renders a single inline <span> element containing the slotted label. An optional leading icon can be slotted before the text, and an optional trailing dismiss button is rendered when is-dismissible is set.

Image showing anatomy of a badge

Item Name Description
1 Icon (optional) An inline SVG or image slotted before the label to reinforce meaning visually
2 Label The slotted text content of the badge
3 Dismiss button (optional) Rendered when is-dismissible is true; emits aegovBadgeDismiss on click

Options

The badge has options for different use cases. These are considered the basic properties that are applicable to a badge.

Approved Approved

Appearance

The appearance property switches between two styles. soft (default) uses a tinted background with a darker, full-saturation label — quieter, suitable for tables and list rows. solid uses a fully filled colour panel with white text — louder, suitable for emphasised counters or critical statuses.

Primary Aegold Aered Techblue Camel

Color palette

The variant property accepts every token in the UAE Design System palette. Use the brand colours (default, primary, secondary, aegold, aered, aegreen, aeblack) for status that aligns with platform identity, and the accent colours (techblue, seablue, camel, desert, fuchsia, slate, purple, pink, indigo, lime) for richer category tagging — 17 tokens in total.

Size

The size property controls the font size, padding, and corner radius of a badge.

Token Font Padding Radius
sm text-xs py-0.5 px-1.5 rounded-sm
base text-sm py-0.5 px-1.5 rounded-md
lg text-sm py-1 px-2 rounded-md, font-medium
Small Base Large
<aegov-badge size="sm" variant="primary">Small</aegov-badge>
<aegov-badge size="base" variant="primary">Base</aegov-badge>
<aegov-badge size="lg" variant="primary">Large</aegov-badge>

Responsive size

size can also be set per breakpoint using a responsive string. Only the three tokens above — sm, base, lg — are valid values at any breakpoint. Pick a value to preview what it resolves to.

Resizes with the viewport
<aegov-badge size="sm md:base xl:lg" variant="techblue">
  Resizes with the viewport
</aegov-badge>

Icons

The default slot accepts any inline content, including SVG icons placed before the label.

Active Pending Rejected

Leading icon

Place an icon before the label to reinforce meaning visually. Icons are sized automatically per badge size — size-3 for sm, size-3.5 for base, and size-4 for lg — so no width/height needs to be declared. Mark decorative icons with aria-hidden="true" so screen readers read only the text label.

<aegov-badge variant="aegreen">
  <svg aria-hidden="true">...</svg>
  Active
</aegov-badge>

Dismissible badge

Set is-dismissible to render a close button at the trailing edge of the badge. Clicking it emits the aegovBadgeDismiss event. The badge does not remove itself from the DOM — your application decides what to do, most commonly removing the host element from a list of active filters.

Abu Dhabi Dubai Sharjah
<div class="flex flex-wrap items-center gap-2">
  <aegov-badge variant="techblue" is-dismissible>Abu Dhabi</aegov-badge>
  <aegov-badge variant="techblue" is-dismissible>Dubai</aegov-badge>
  <aegov-badge variant="techblue" is-dismissible>Sharjah</aegov-badge>
</div>

<script>
  document.querySelectorAll('aegov-badge[is-dismissible]').forEach(b => {
    b.addEventListener('aegovBadgeDismiss', () => b.remove());
  });
</script>

Common uses

A common use for a badge is to mark the status of a row in a service list, or as a numerical counter next to a navigation item.

  • Emirates ID renewal Active
  • Driving licence transfer Pending
  • Vehicle registration Expired

Status indicators

Pair colours consistently across your application so users learn the meaning at a glance — for example, always use aegreen for active states and aered for errors or expiry.

Inbox 12 Notifications 3

Counters

Small solid badges work well as numerical counters next to navigation items, tabs, or icons. Use size="sm" for the most common counter footprint, and add visually hidden text (for example <span class="sr-only">unread messages</span>) so the count is announced in context — an aria-label on the badge is not reliably announced.

RTL support

The badge is direction-agnostic. The dismiss button's spacing flips based on dir="rtl", so in an RTL container it automatically renders on the inline-end (visually the left side). No extra configuration is required — pass real Arabic content into the slot and the layout flips correctly.

نشِط قيد الانتظار تصنيف: أبوظبي
<div dir="rtl">
  <aegov-badge variant="aegreen">نشِط</aegov-badge>
  <aegov-badge variant="camel">قيد الانتظار</aegov-badge>
  <aegov-badge variant="techblue" is-dismissible>تصنيف: أبوظبي</aegov-badge>
</div>

Usage

Here is the recommended usage of a badge on any website or application. These are recommended usage guides, however the developer must use the best practices of web and application development to accurately use this component.

Pair colour with explicit text

Colour alone is not sufficient to convey status. Always label the badge with a word such as "Active" or "Suspended" so meaning does not depend on colour perception alone.

Keep colour meaning consistent

Assign one colour per status meaning across the whole application (for example, aegreen always means active) and keep that mapping consistent on every screen so users learn it once.

Do not use a badge as a button

A badge is not an interactive control on its own — only its optional dismiss button is interactive. Do not attach click handlers to the whole badge for navigation or actions; use aegov-button or aegov-link instead.

Do not overuse the solid appearance

The solid appearance is louder and reserved for emphasised counters or critical statuses. Using it everywhere reduces visual hierarchy and makes true priorities harder to spot.

Do not stuff long sentences into a badge

Badges are meant to be compact. Keep the label to a short word or count; move longer explanations into surrounding content or a tooltip.

API reference

The following are the properties and references of a badge

aegov-badge default properties

AttributeDescriptionTypeDefault

field-id

DOM id for the inner <span> element. Auto-generated as aegov-badge-{n} if omitted.

string

auto-generated

variant

Colour token from the UAE Design System palette.

default | primary | secondary
aegold | aered | aegreen | aeblack
techblue | seablue | camel | desert
fuchsia | slate | purple | pink | indigo | lime

default

appearance

Visual style — tinted background, or a fully filled panel.

soft | solid

soft

size

Size token. Accepts a single token or a Tailwind-style responsive string.

sm | base | lg

base

is-dismissible

Renders a close button at the trailing edge of the badge.

boolean

false

Events

EventsDescriptionComponentDetail

aegovBadgeDismiss

Fired when the dismiss button is clicked. The badge does not remove itself from the DOM.

aegov-badge

void

<aegov-badge field-id="filter-region" variant="techblue" is-dismissible>
  Region: Abu Dhabi
</aegov-badge>

<script>
  document.querySelector('#filter-region').addEventListener('aegovBadgeDismiss', () => {
    document.querySelector('#filter-region').remove();
  });
</script>

Slots

SlotDescription

(default)

The badge label. Plain text or simple inline HTML, including a leading icon.

Pass-through attributes

AttributeNotesForwards to

aria-*

Any aria tag not automatically added. Copied to the inner <span> and also kept on the host. The <span> has no role, so an aria-label there is not reliably announced — put context in text instead (see Accessibility).

inner <span>

data-*

Any custom "data" attribute. Useful for analytics or styling hooks.

inner <span>

id

Use field-id on the host instead. The inner <span> reflects that value.

n/a

Notes

The following notes are applicable of this component.

Built-in accessibility

  • The dismiss button is a real <button type="button">, so it is focusable, keyboard-activatable, and exposed correctly to assistive technologies by default.
  • The dismiss button's aria-label is context-aware — it automatically includes the badge's text content, so screen readers announce "Dismiss Approved", "Dismiss Error", etc. rather than a generic label. The text is read once, when the badge first loads — if the label changes afterwards, the dismiss label keeps the original text, so re-create the badge rather than editing its text in place. When the badge has no text it falls back to "Dismiss badge" ("إغلاق الشارة" in RTL).
  • The dismiss button maintains a minimum touch target of 24 × 24 CSS px on every badge size (sm, base, lg), satisfying WCAG SC 2.5.8.
  • The dismiss SVG icon is aria-hidden="true" — all meaning is carried by the button's aria-label.
  • The dismiss-click handler calls event.stopPropagation(), so a parent click handler does not also fire when a badge is dismissed.
  • aria-* and data-* attributes set on the host are forwarded to the inner <span>.

Developer responsibility

The following is required for a developer to add additionally or pay attention to regarding this component.

  • Provide meaningful text inside the badge. Colour alone is not sufficient to convey status — pair colour with explicit words such as "Active", "Pending", or "Suspended".
  • For badges acting as numerical counters, give the count its context in text, for example <aegov-badge>3 <span class="sr-only">unread messages</span></aegov-badge>. An aria-label on the host is copied to a role-less <span>, and screen readers do not reliably announce names on elements without a role.
  • After a dismiss, remove the badge and move focus to a sensible element (the next badge, or the filter group) — the focused dismiss button disappears with it.
  • If a badge's value changes over time, consider wrapping it (or its surrounding container) in an aria-live="polite" region so assistive technology announces the update.
  • Removing the badge from the DOM after dismiss is the consumer's responsibility — the component emits aegovBadgeDismiss but does not auto-remove itself.
  • Mark decorative inline icons with aria-hidden="true". The badge text is the sole accessible label.

Additional notes

  • Icons placed inside the slot inherit sizing automatically based on the size prop — you do not need to set width/height on the icon.
  • Tab moves focus to the dismiss button when present; Enter or Space activates it. A non-dismissible badge is not focusable and is not part of the tab order.