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 Banner

Banner

A Banner is a page-level notification pinned to the top or bottom of the viewport. Use it for messages that apply to the whole site or service — scheduled maintenance, regional alerts, cookie consent, ministry-wide announcements, or critical system errors that must remain visible while users scroll.

Feedback Interactive
Status
Active
Introduced
4.0.x
View source code

Anatomy

The aegov-banner component renders a full-width bar pinned to the top or bottom of the viewport, with a variant icon, message content, optional action buttons, and an optional dismiss control.

Image showing anatomy of a banner

Item Name Description
1 Variant icon Automatic icon matching the variant, or a custom icon slot
2 Content The slotted message text
3 Actions Optional row of buttons under the message via the actions slot
4 Dismiss button Closes the banner, shown unless is-dismissible="false"

Every live preview on this page uses display="sticky" mode="overlay" inside a bounded, scroll-clipped container so the banners stay put for the demo instead of pinning to the real page viewport or shifting this page's own layout. The copy-paste code underneath each preview shows the real recommended defaults — display="fixed" mode="push" — which is what you should actually use in production.

Variants

The variant property sets the colour scheme and the implicit ARIA role. Only error resolves to role="alert"; success, info, warning, and default all resolve to role="status".

A neutral, informational message. Useful information about your service. Your Emirates ID renewal application has been received. Your residency permit expires in 14 days — renew before 15 May. The payment gateway is temporarily unavailable.
<aegov-banner variant="default">A neutral, informational message.</aegov-banner>
<aegov-banner variant="info">Useful information about your service.</aegov-banner>
<aegov-banner variant="success">Your Emirates ID renewal application has been received.</aegov-banner>
<aegov-banner variant="warning">Your residency permit expires in 14 days — renew before 15 May.</aegov-banner>
<aegov-banner variant="error">The payment gateway is temporarily unavailable.</aegov-banner>

Appearance

soft (default) uses a tinted background suitable for ongoing notices. solid uses a fully saturated colour panel for high-priority alerts that must dominate the viewport.

Soft — scheduled maintenance window starts at 22:00 tonight. Solid — critical: identity verification service outage.
<aegov-banner appearance="soft" variant="warning">
  Scheduled maintenance window starts at 22:00 tonight.
</aegov-banner>

<aegov-banner appearance="solid" variant="error">
  Critical: identity verification service outage.
</aegov-banner>

Position, display strategy, and mode

position (top | bottom) chooses which viewport edge the banner pins to. display chooses the CSS mechanism — fixed (default) stays glued to that edge regardless of scroll, sticky scrolls with the page until it reaches the edge, then sticks. mode chooses the layout strategy — push (default, only with display="fixed") adds matching padding to <body> so page content is never covered; overlay floats above content instead and emits aegovBannerHeightChange so you can react to its height yourself.

These three properties genuinely pin an element to the real page viewport and mutate <body>'s padding, so — matching the reference project's own documentation approach — this page does not attempt to live-preview them in isolation; every other live example on this page already demonstrates the safe display="sticky" mode="overlay" combination in a contained box. Use the code below directly in your own page to see real fixed/push behaviour.

<!-- Pinned to the bottom instead of the default top -->
<aegov-banner position="bottom" variant="default">
  We use cookies to improve your experience. By continuing you accept our cookie policy.
</aegov-banner>

<!-- display: sticky — scrolls with the page, then sticks once it reaches the edge -->
<aegov-banner display="sticky" variant="warning">
  Sticks once scrolled into place.
</aegov-banner>

<!-- mode: overlay — floats over content and reports its own height -->
<aegov-banner mode="overlay" position="top" variant="info" id="floatBanner">
  This banner floats over content; subscribe to height changes for layout sync.
</aegov-banner>

<script>
  document.getElementById('floatBanner')
    .addEventListener('aegovBannerHeightChange', () => {
      // With display="fixed" the host has no in-flow height, so measure the rendered bar.
      const bar = document.querySelector('#floatBanner .aegov-banner');
      document.body.style.setProperty('--banner-height', (bar ? bar.offsetHeight : 0) + 'px');
    });
</script>

Size

The size property scales font size and vertical padding. Three tokens are available: sm, base (default), and lg.

Small — UAE Pass authentication is now available for citizens and residents. Base — UAE Pass authentication is now available for citizens and residents. Large — UAE Pass authentication is now available for citizens and residents.
<aegov-banner size="sm" variant="info">UAE Pass authentication is now available for citizens and residents.</aegov-banner>
<aegov-banner size="base" variant="info">UAE Pass authentication is now available for citizens and residents.</aegov-banner>
<aegov-banner size="lg" variant="info">UAE Pass authentication is now available for citizens and residents.</aegov-banner>

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-banner size="sm md:base xl:lg" variant="info">
  Resizes with the viewport.
</aegov-banner>

Actions

The actions slot holds buttons or links in a wrapping row under the message. When it has content, the message spans the full width instead of being centred as a block — the standard pattern for cookie consent or a call to action. aegov-button, aegov-link and plain links in the slot are recoloured to match the banner's variant and appearance.

We use cookies to improve your experience on the UAE Government services portal.
Accept all Manage preferences
<aegov-banner variant="info" position="bottom" is-dismissible="false">
  We use cookies to improve your experience on the UAE Government services portal.
  <div slot="actions">
    <aegov-button size="sm">Accept all</aegov-button>
    <aegov-button size="sm" appearance="outline">Manage preferences</aegov-button>
  </div>
</aegov-banner>

Dismiss control

By default a close button renders. Set is-dismissible="false" for messages the user is not allowed to dismiss — legal notices, mandatory cookie consent. The close button runs a 300ms exit animation; aegovBannerDismiss fires once it completes. Click the close button below to try it.

Dismissible reminder — your residency expires in 14 days.
<aegov-banner id="alertBanner" variant="warning">
  Dismissible reminder — your residency expires in 14 days.
</aegov-banner>

<script>
  document.getElementById('alertBanner')
    .addEventListener('aegovBannerDismiss', () => {
      console.log('User dismissed the renewal reminder');
    });
</script>

Critical alerts and heading association

Set is-focusable="true" for alerts that demand immediate attention — the banner focuses itself on mount. This only takes effect when the resolved role is alert, which variant="error" produces (or a role="alert" set on the host); it has no effect on success, info, warning, or default banners. Use it sparingly, since it interrupts the user's current keyboard focus.

There is no heading prop. To label the banner for assistive technology, set aria-labelledby on the host pointing at the id of a heading you render yourself inside the default slot — the attribute is copied to the inner banner element. field-id sets that inner element's own id.

This page does not auto-focus either example live, since stealing keyboard focus unexpectedly while reading documentation would itself be disruptive — the behaviour is exactly as described above when used on a real page.

<aegov-banner variant="error" is-focusable="true">
  The Emirates ID renewal service is temporarily offline. Please try again in 30 minutes.
</aegov-banner>

<aegov-banner field-id="maintenance" aria-labelledby="maintenance-heading">
  <strong id="maintenance-heading">Maintenance window</strong>
  Government services will be briefly unavailable on Friday 03:00–05:00 GST.
</aegov-banner>

RTL support

The banner is direction-agnostic — internal spacing uses logical properties, so the icon (inline start) and the dismiss button (inline end) swap sides automatically under dir="rtl". The dismiss button's label is localised from the nearest dir ancestor or <html dir>: "Close banner" in English, "إغلاق الشريط" in Arabic.

تذكير: تنتهي صلاحية بطاقة الهوية الإماراتية الخاصة بك خلال 14 يوماً. يُرجى تجديدها قبل 15 مايو.
جدّد الآن تذكيري لاحقاً
<div dir="rtl">
  <aegov-banner variant="warning">
    تذكير: تنتهي صلاحية بطاقة الهوية الإماراتية الخاصة بك خلال 14 يوماً. يُرجى تجديدها قبل 15 مايو.
    <div slot="actions">
      <aegov-button size="sm">جدّد الآن</aegov-button>
      <aegov-button size="sm" appearance="outline">تذكيري لاحقاً</aegov-button>
    </div>
  </aegov-banner>
</div>

Usage

Here is the recommended usage of a banner 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.

Reserve it for page- or site-wide messages
A banner interrupts every page it appears on. Use it for something that affects the whole visit — an outage, a policy change, a deadline — not a single form's validation error.

Match variant to real severity
error interrupts screen reader users immediately. Reserve it for something the user must act on now; use info, success, or warning for everything else.

Let the user dismiss non-critical banners
Keep is-dismissible (the default) for anything the user doesn't strictly need to act on, so it doesn't keep occupying screen space after they've read it.

Do not stack more than one banner at a time
Multiple simultaneous banners compete for the same prime real estate and for the user's attention. Queue messages and show the single most important one instead.

Do not use a banner for content specific to one section of the page
A banner reads as applying to the whole page. Content scoped to one form, card, or section belongs in an aegov-callout instead.

Do not make critical, unmissable notices dismissible
Legal notices and mandatory consent messages should set is-dismissible="false" — a user who closes the message before reading it defeats its purpose.

API reference

The following are the properties and references of a banner

aegov-banner default properties

AttributeDescriptionTypeDefault

field-id

DOM id for the inner banner element (the one carrying the role). Auto-generated (aegov-banner-N) and reflected if omitted. No heading id is derived from it — give your own heading an id and reference it with aria-labelledby.

string

auto-generated

variant

Colour scheme and implicit ARIA role. Only error resolves to role="alert" — every other variant resolves to role="status".

default | error | warning | success | info

default

appearance

soft uses a tinted background; solid uses a fully saturated colour panel.

soft | solid

soft

position

Edge of the viewport the banner pins to.

top | bottom

top

display

CSS positioning strategy. fixed stays glued to the edge regardless of scroll; sticky scrolls with the page until it reaches the edge, then sticks.

fixed | sticky

fixed

mode

push adds matching padding to <body> so page content is never hidden underneath (only takes effect with display="fixed"). overlay floats above content and emits aegovBannerHeightChange instead.

push | overlay

push

size

Font size and vertical padding. Accepts a single token or a Tailwind-style responsive string.

sm | base | lg

base

is-dismissible

Whether a close button renders.

boolean

true

is-focusable

Gives the inner banner element tabindex="-1" and focuses it once on load. Only has an effect when the resolved role is alert (variant="error", or role="alert" set on the host) — a success/info/warning/default banner resolves to role="status", so is-focusable does nothing on those.

boolean

false

Events

EventDescriptionDetail

aegovBannerDismiss

Fires once the 300ms exit animation completes after the close button is clicked.

CustomEvent<void>

aegovBannerHeightChange

Fires in mode="overlay" on load, whenever the host resizes, and with { height: 0 } after dismiss. height is the host's offsetHeight; with display="fixed" the host takes no space in the flow and reports 0, so measure the rendered .aegov-banner element instead.

CustomEvent<{ height: number }>

Slots

SlotDescription

(default)

Banner message content.

actions

Action buttons or links, rendered in a wrapping row under the message. When present, the message spans the full width instead of being centred as a block. aegov-button, aegov-link and plain links inside are recoloured to match the banner.

icon

Custom icon shown at the inline start, replacing the automatic variant icon. The icon column is always aria-hidden="true", so the icon must be decorative.

Pass-through attributes

AttributeNotesForwards to

aria-*

Copied to the inner banner element; also stays on the host.

inner <div>

data-*

Copied to the inner banner element; also stays on the host.

inner <div>

role

When set on the host, overrides the auto-computed role (e.g. downgrade an error banner from alert to status).

inner <div>

id

Not forwarded. Use field-id to control the inner element's actual id.

n/a

There is no heading prop. To label the banner for assistive technology, set aria-labelledby on the host pointing at the id of a heading you render yourself inside the default slot — the relationship is not created automatically.

Notes

The following notes are applicable of this component.

Built-in accessibility

  • The role auto-computes from variant — only error resolves to role="alert" (assertive, interrupts immediately); success, info, warning, and default all resolve to role="status" (polite, announced when the screen reader is idle).
  • Neither role sets an explicit aria-live attribute — both alert and status carry their aria-live value implicitly per the WAI-ARIA specification, which is the behaviour recommended by the APG Alert pattern.
  • A built-in variant icon renders automatically alongside the text, so severity is conveyed by shape as well as colour (WCAG SC 1.4.1). The icon column is aria-hidden="true" — the slotted text is the sole accessible announcement.
  • The dismiss button has aria-label="Close banner" ("إغلاق الشريط" under dir="rtl") and its icon is aria-hidden="true".
  • In display="fixed" mode="push", body padding is set and cleared automatically via a ResizeObserver so page content is never hidden underneath, and is also cleared on dismiss and on disconnect.

Developer responsibility

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

  • Choose variant thoughtfully — role="alert" interrupts screen reader users immediately. Reserve error for messages that genuinely require immediate attention.
  • There is no heading prop. Setting aria-labelledby on the host only creates the ARIA relationship — you must still render the heading element yourself inside the default slot with a matching id.
  • Use is-focusable="true" sparingly — it steals keyboard focus on mount, which is disruptive outside genuinely critical alerts, and only ever takes effect when the resolved role is alert.
  • Use only one display="fixed" mode="push" banner per edge — each one writes <body>'s inline padding-top or padding-bottom and overwrites any other inline value there.
  • A dismissed banner cannot be reopened: the host stays in the DOM, empty. Remove it and create a new element to show it again.

Additional notes

  • The size property is responsive-string capable (size="sm md:base xl:lg"), matching the same mechanism used by Badge and Accordion.
  • mode="overlay" is intended for layouts that reserve their own space for the banner — subscribe to aegovBannerHeightChange and apply the height to your own layout (a CSS custom property, for example) rather than relying on automatic body padding, which only applies in mode="push".

Keyboard support

Key Action
Tab Move focus into the banner (any controls in the actions slot, then the dismiss button).
Enter, Space Activate the focused control.
Shift + Tab Move focus backwards.