Alert

Contextual feedback messages for user actions or system status. Supports multiple severity levels with optional actions and dismissibility.

Setup

import { Alert } from '@fragments-sdk/ui';

Examples

Info

Informational context for the user

Loading preview...

Success

Positive confirmation of completed action

Loading preview...

Warning

Caution about potential issues

Loading preview...

Error

Error state requiring user attention

Loading preview...

With Action

Alert with an actionable button

Loading preview...

Dismissible

Alert that can be closed by the user

Loading preview...

Props

PropTypeDefaultDescription
childrenRequirednodeNot setAlert content - use Alert.Icon, Alert.Body, Alert.Title, Alert.Content, Alert.Actions, Alert.Close sub-components
severityenuminfosuccesswarningerrorinfoVisual severity level

Usage Guidelines

When to use

  • Communicating the result of a user action (success, error)
  • Warning about potential issues before they occur
  • Providing important contextual information inline
  • System status notifications that require attention

When not to use

  • Brief status labels (use Badge instead)
  • Transient notifications (use Toast/Snackbar)
  • Form-field-level errors (use Input error prop)
  • Confirmation before destructive actions (use Dialog)

Best practices

  • Match severity to the actual importance: info for context, warning for potential issues, error for failures
  • Always provide actionable guidance in error alerts
  • Use Alert.Title for complex messages; skip titles for brief one-liners
  • Limit to one action per alert to avoid decision paralysis
  • Use Alert.Close only for non-critical information
  • Alert.Action and Alert.Close render buttons with type="button" by default (safe inside forms)
  • Alert.Close composes your onClick handler with built-in dismiss behavior and respects preventDefault()
  • Alert sub-components forward DOM props (aria-*, data-*, id, handlers) to their rendered elements
Accessibility
  • Uses role="alert" for screen reader announcement
  • Error and warning alerts are announced immediately by assistive technology
  • Alert.Close must have an accessible label
  • Color alone must not convey meaning - icons and text reinforce severity