Skip to content

Alert

Get Ritla UI

A message in the page, next to what it's about, that stays until the situation changes or the person dismisses it: a failed payment, an expiring ID, a finished import.

Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add alert

    Also works with shadcn: npx shadcn@latest add @ritla/alert

  2. Dependencies it brings

    @phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

alert.tsx
import { Alert } from "@/components/ui/alert";<Alert type="warning" title="Your ID expires on 12 October" action={{ label: "Upload ID", href: "/id" }}>  Upload a new ID before then to keep sending money.</Alert>

Examples

Types and emphasis

Type says what the message is; emphasis says how loud: Light for most alerts, Subtle for ones people should notice, Intense for the one critical problem on a page.

EnglishMirroredArabic
LTR →

Dismissible

dismissible for alerts that only inform. On dismiss, focus moves on to the next control. Remembering the dismissal is up to the app (onDismiss).

EnglishMirroredArabic
LTR →

Form error summary

After a failed submit an Error alert appears above the form (announce="alert"), focus moves to it, and its links go to the fields. Submit the form empty to see it.

EnglishMirroredArabic
LTR →

API reference

Alert

PropTypeDefaultDescription
type"information" | "success" | "warning" | "error""information"Figma's Type.
emphasis"light" | "subtle" | "intense""light"Figma's Emphasis.
titleReactNodeNoneFigma's Title: what happened.
childrenReactNodeNoneFigma's Message: what to do about it.
iconIconComponent | nullNoneFigma's Show leading icon; one per type by default.
action / link{ label; href?; render?; onClick? }NoneFigma's Show Button and Show link.
announce"status" | "alert"NoneFor alerts that appear after something happens; alert for urgent errors only.
dismissible / dismissLabel / onDismissboolean / string / () => voidNoneFigma's Show dismiss, the button's name, and what dismissing does.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabTo the action, the link and the dismiss button; after dismissing, focus moves to the next control.

ARIA

  • An alert that's there when the page loads is part of it; one that appears after something happens takes status, an urgent error alert.
  • Color never works alone: the icon and the title say the type.
  • The dismiss button has a name (Dismiss).

Arabic and RTL notes

Mirrors

  • The icon, title and message sit on the right, the dismiss button on the left, and the actions start on the right.

Does not mirror

  • The information, success, warning and error icons don't mirror.
Numerals
Dates, amounts and IDs read left to right inside <bdi dir="ltr">.
Arabic typography
Title body-14 Semibold, message body-14; the height is a minimum.
Mixed-direction text
Write the Arabic title and message natively, not word for word.

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R012Untranslated attribute text (placeholder, alt, title, aria-label, button value)
  • R022text-align: left explicitly set on majority-Arabic text
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space
  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)