Documentation

Alert

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

WebStableRetours

Web uniquement — React, depuis @krizaka/ui/alert. Stable : son API ne change qu’à une version majeure.

Quand l’utiliser

  • 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”.

Quand ne pas l’utiliser

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

Installation

Installer

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

Styles

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

Importer

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

Exemples

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

PropTypeDéfautDescription
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.

Accessibilité

  • 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.

Bonnes pratiques

  • 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.

Générée depuis le code de @krizaka/ui 2.0.0-beta.6 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page