Purpose

Notification bars are used to show informational, warning, or error alerts. Since they communicate app-level information, they are placed across the top of the screen.

Dos

  • Keep messaging clear and short
  • Stay within the recommended 100 character limit
  • Add optional in-line links only at the end of the message and use sparingly

Don’ts

  • Show more than one notification bar at a time
  • Use for low-attention messages, such as simple confirmations of user action (instead, use Toasts)
  • Use for feature- or page-level loading errors, which can confuse the user

Usage

import {NotificationBar} from '@loomhq/lens'
<NotificationBar>Content</NotificationBar>

Variants

Variants are determined by severity level, which is dictated in the code.

  • info (default) — general messages
  • warning — higher importance messages that are non-blocking to the user now, but may cause issues later
  • error — urgent messages that are blocking the user right now
  • internal — local warnings for Loom engineers

Accessibility

Out of box, the NotificationBar has the following properties built in:

  • Color accessibility: All variants meet WCAG AA contrast
  • Navigability: Focusable and togglable by every input device (mouse, keyboard, switch, etc).
  • Screenreader support:
    • The NotificationBar is an aside element, as it is complementary to the main body of the page
    • The message body (usually the error or confirmation) is set with role is set to either status or alert depending on the severity of the message
    • Info: status is less assertive and uses aria-live=”polite”, which waits until the screenreader user is idle to announce the message
    • Error/Warning: alert is more assertive and uses aria-live=”assertive”
    • (MDN docs), immediately to inform the user of the time-sensitive error
    • The X representing “Close” has an aria-label of “Close notification bar”

Examples

Standard

Severity Levels

The three severity levels are directly tied to the error generated in the code.

internal is for alerting engineering Loommates of issues in the local environment. Internal alerts are not user-facing and will never appear in staging or production environments.

Optional onCloseClick

Props

name
type
default
severity
SeverityLevels
'info'
children
React.ReactNode
isOpen
boolean
onCloseClick
() => void