Documentation

Alert

A message in the flow of the page: a tone, an icon, a title, a text and an optional action.

WebStableFeedback

Web only — React, from @krizaka/ui/alert. Stable: its API only changes in a major version.

When to use

  • To tell the reader something about the whole page or section: a new rule, an account state, a failed payment.
  • When the message must stay visible until the situation changes (a low balance, an expired card).
  • With an action when there is one obvious next step: “Top up”, “Retry”.

When not to use

  • For the result of an action the user just took (saved, sent): it should come and go.Use instead: Toast
  • When the user must answer before going on.Use instead: Dialog
  • To explain why a field is invalid: put the error under the field.Use instead: Field
  • When a list or a panel has nothing to show.Use instead: Empty state

Installation

Install

npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Import

import { Alert } from "@krizaka/ui/alert";

Examples

Info

The default tone: news the reader should know, announced politely.

New payout schedule

Payouts now arrive every Monday.

Success

A state that is now good: verified, paid, connected.

Account verified

You can now receive payouts.

Warning

Something will go wrong soon, with what to do about it.

Danger

Something went wrong: what failed and how to fix it.

Title only

A short message needs no icon and no text.

New payout schedule

Props

PropTypeDefaultDescription
actionReactNode—What to do: a Button, a link.
iconReactNode—A decorative icon (hidden from assistive technology).
titleReactNode—The headline, in bold above the text.
toneAlertToneinfoThe tone: danger and warning are announced at once (role="alert"), info and success politely.

Accessibility

  • danger and warning render role="alert" (announced at once); info and success render role="status" (announced politely).
  • Render the alert when the situation occurs, not before: a live region only announces content that changes.
  • The icon is hidden from assistive technology; the title and the text carry the meaning.

Best practices

  • Lead with the title: what happened, in a few words; the text says what it means or what to do.
  • danger and warning only for what needs attention now: an alert that is always there stops being read.
  • The icon is decorative and the tone is carried by the tint, the border and the icon: the text stays legible in both themes.

Generated from the code of @krizaka/ui 2.0.0-beta.6: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page