Skip to content
EspañolEnglish
All components (204)

Global alert

Surfaces · GlobalAlert · .amset-banner

What it is and when to use it

The full-width ribbon at the top of the page: a maintenance shutdown, a trial about to expire, an incident. It speaks about the whole application, not about what is being filled in.

When to use it

  • Notices that apply to any screen: a scheduled shutdown, an outside service being down, the end of the trial period.
  • variant="solid" for an outage or a block that cannot go unnoticed; soft (default) for the rest.
  • size: sm for a ribbon that accompanies without getting in the way (the test environment), lg for an outage.
  • action for a button or a link on the right ("Renew", "View details"). In windows narrower than 40rem it drops to its own line and the cross stays at the top, in its corner.
  • fixed keeps it attached to the top when scrolling (position: sticky), for maintenance or outages.
  • centered centers the text when the ribbon is short and takes up the whole screen.
  • onClose when it can be dismissed. The ribbon does not remove itself: whoever draws it removes it, on receiving the call.

When not to

  • What concerns the form or the card being viewed: Alert.
  • A network outage: ConnectionStatus, which already listens to the browser.
  • Cookie consent: CookieBanner.

Keyboard: the ribbon is not focusable. The close button (with onClose) and whatever goes in action have their own Tab stop; Enter and Space press the close button.

Accessibility: with tone="error" it is role="alert" and interrupts; the rest, role="status", wait their turn, because an informational ribbon has no reason to cut off what is being read. announcement forces it (alert, status or none). The icon is decorative (aria-hidden) and each tone has its own silhouette: a triangle for the warning, an octagon for the error; icon changes it and withoutIcon removes it. The cross is seen at 24 to 32 px and pressed at 44 × 44 with a finger; it is named "Close the notice" and closeLabel changes it.

Fine-tuning: CSS variables --amset-banner-*: -padding-block, -padding-line, -slot, -font, -icon and -close; the tone colors, in --amset-banner-tone, -tone-soft, -tone-solid and -tone-ink. fixed is sticky at the top, in the --amset-layer-sticky layer.

What it looks like

Saturday's maintenance will leave the store without orders from 02:00 to 04:00.

<GlobalAlert tone="warning">
  El mantenimiento del sabado dejara la tienda sin pedidos de 02:00 a 04:00.
</GlobalAlert>

Props

Import it with import { GlobalAlert } from '@amset/ui'. Required props are marked.

PropTypeWhat it does
childrenrequiredReactNode—
actionReactNodeA button or a link on the right: "Renew", "View details".
announcementAlertAnnouncementForces how it is announced. By default an error interrupts and the rest wait their turn.
centeredbooleanCenters the text when the ribbon is short and takes up the whole screen.
classNamestringMerged with the library classes; it does not replace them.
closeLabelstring—
fixedbooleanIt stays stuck to the top when scrolling. For maintenance or outages.
iconReactNodeOwn icon instead of the one that applies by tone.
onClose() => void—
size"sm" | "md" | "lg"`sm` for a ribbon that accompanies (test environment); `lg` for an outage.
tone"neutral" | "accent" | "secondary" | "tertiary" | "info" | "success" | "warning" | "error"What it means. Defaults to `info`.
variantGlobalAlertVariant—
withoutIconbooleanNo icon: for purely informational banners.

It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

CSS variables

These CSS variables are how you adapt it. Declare them on the component's selector, not on :root: the stylesheet redeclares them in the rule itself, and a declaration on the same element always wins.

VariableDefault
--amset-banner-tonevar(--amset-info)
--amset-banner-tone-softvar(--amset-info-soft)
--amset-banner-tone-solidvar(--amset-info-solid)
--amset-banner-tone-inkvar(--amset-info-ink)
--amset-banner-padding-blockvar(--amset-space-3)
--amset-banner-padding-linevar(--amset-space-4)
--amset-banner-slotvar(--amset-space-3)
--amset-banner-fontvar(--amset-text-base)
--amset-banner-icon1.125rem
--amset-banner-close1.75rem
--amset-banner-backgroundvar(--amset-banner-tone-soft)
--amset-banner-bordercolor-mix(in oklab, var(--amset-banner-tone) 30%, transparent)
--amset-banner-textvar(--amset-banner-tone)

How to change it

.amset-banner {
  --amset-banner-tone: ...;
  --amset-banner-tone-soft: ...;
}

In the test bench

Every state and variant, to try one at a time, on its page at ui.amset.tech: