Skip to content
Focsd homeFocsd homeFocsd
Forms

Alert / banner

A message about the state of something, with tone, title and optional actions.

  • Tag: focsd-alert
  • Pattern: Alert / status
  • Category: Feedback

Example

Your workspace name now appears on new invoices. You are using 9 of 10 seats. The card ending 4242 was declined. Sunday 02:00–03:00 UTC.
HTML
<div class="stack">
<focsd-alert tone="positive" headline="Changes saved" closable
>Your workspace name now appears on new invoices.</focsd-alert
>
<focsd-alert tone="caution" headline="Seat limit almost reached"
>You are using 9 of 10 seats.</focsd-alert
>
<focsd-alert tone="critical" headline="Payment failed"
>The card ending 4242 was declined.</focsd-alert
>
<focsd-alert tone="info" headline="Scheduled maintenance"
>Sunday 02:00–03:00 UTC.</focsd-alert
>
</div>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-alert.js';
</script>
<focsd-alert tone="positive" headline="Changes saved" closable>Your workspace name now appears on new invoices.</focsd-alert>

API

Attributes

AttributePropertyTypeDefault
tonetone'neutral' | 'info' | 'positive' | 'caution' | 'critical'neutral
iconiconstring—
icon-libraryiconLibrarystring—
headlineheadlinestring—
livelive'off' | 'polite' | 'assertive'off
closableclosablebooleanfalse

Events

EventDescription
closeFired when the close button is pressed, before the alert hides; cancel it to keep the alert.

Slots

SlotDescription
(default)Default content.
actionsButtons or links for the alert.
iconAny icon markup (an SVG, an icon component, an icon-font element) instead of the tone's icon.

CSS parts

Style the inside of the component with ::part(), for example focsd-alert::part(actions).

PartDescription
actionsThe actions element.
alertThe alert element.
bodyThe body element.
closeThe close (×) button, with `closable`.
contentThe content element.
headlineThe headline element.
iconThe icon element.

Accessibility

  • Static by default. Set live="polite" (role="status") or live="assertive" (role="alert") only when the alert appears in response to something.
  • Tone always comes with an icon and a headline in words, never color alone.
  • closable adds a close (×) button named "Close". It fires a cancelable close (it does not bubble), then hides the alert; cancel it to keep the alert or to remove it yourself.