Skip to Content
DocsComponentsAlert

Alert

A brandless status notification container wrapping a <div role="alert">. The role attribute identifies the element as an ARIA live region — screen readers announce its content when it appears. All visual styling is driven by CSS custom properties.

Demo

Usage

import { Alert } from '@froglet/ui' <Alert>Your changes have been saved.</Alert> // Lower urgency <Alert role="status">Loading complete.</Alert> // Themed with a modifier class <Alert className="alert--success">Your changes have been saved.</Alert> <Alert className="alert--error">Something went wrong. Please try again.</Alert>

Props

PropTypeDescription
childrenReactNodeAlert content.
classNamestringAdditional CSS classes. Use to apply a token block.
rolestringARIA role. Defaults to "alert". Override with "status" for lower urgency.
refReact.Ref<HTMLDivElement>Forwarded to the underlying <div>.
...propsHTMLAttributes<HTMLDivElement>All standard div attributes.

CSS Custom Properties

TokenDefaultDescription
--alert-padding0.75rem 1remInner spacing.
--alert-background-color#f9fafbBackground fill.
--alert-text-color#374151Text color.
--alert-border-width1pxBorder width.
--alert-border-stylesolidBorder style.
--alert-border-color#e5e7ebBorder color.
--alert-border-radius4pxCorner rounding.

Accessibility

  • role="alert" marks the element as an ARIA live region with aria-live="assertive". Screen readers interrupt the user to announce the content when it is inserted into the DOM.
  • Use role="status" for non-urgent status messages that should not interrupt.
  • Do not use Alert as a decorative container — only when the content is a genuine notification.
Last updated on