Actions and feedback
Alert, Banner, Progress, Spinner, Toaster, toast and StatusBadge
Scheduled maintenancePublishing is paused tonight from 2:00 AM to 2:30 AM.
Storage is almost full
Uploads stop at 100% of the quota.
Backup finished
The latest backup is 4 minutes old.
64%
Loading documentsPublishedIn reviewDraft
When to use
Alert: an important state on a page that must not disappear by itself.Banner: service degradation, server maintenance, an expired subscription — anything that concerns the whole app and survives navigation.toast: "saved", "failed to send"; a singleToastergoes at the app root.Progress: the percentage/fraction is known;value={null}means indeterminate progress.Spinner: neither the duration nor the future shape of the content is known.StatusBadge: a compact domain status, such as a publication or a channel.
When not to use
- Do not use a
toastfor a lasting error — that is anAlert. - Do not use
Bannerfor a message about one block of the page — that is anAlert. The line is drawn by place and lifetime:toastreports an event,Alertdescribes the state of a place, andBannerdescribes the state of the app. - Do not show
Progressat zero when the amount is unknown: passnull. - Do not replace a
Skeletonwith aSpinnerwhen the shape of the result is known. - Do not use
StatusBadgeas a clickable filter — that is aChip.
Minimal example
<Alert tone="danger" title="Publishing is unavailable">Connect a channel.</Alert>
<Progress label="Uploading files" value={64} showValue />
<StatusBadge tone="success">Published</StatusBadge>
// Next to the app root:
<Toaster />
// In a handler:
toast.success("Saved");Public API
Alert:tone,variant(soft/outline),title,icon,action,onDismiss,closeLabel;dangergetsrole="alert"and the other tones getrole="status".Banner:tone,title,icon,action,onDismiss,closeLabel. There is novariant— a banner is always a full-width strip with no rounded corners. The role follows the tone, as inAlert. A stack is just adjacent banners: the component has no queue.Progress: requiredlabel,value: number | null,showValue;nulldoes not setaria-valuenow.Spinner:size,tone,label(from the message catalog: "Загрузка" with@olddevs/ui/locales/ru, "Loading" without a provider) androle="status".Toaster:position,duration(4000 ms by default),theme,offsetVar.offsetVaris the name of the variable holding the bottom bar height,--bottombar-hby default. At the bottom edge toasts sit above theMobileTabBarin thebottomBarslot ofAppShellrather than under it; with no bar the offset is unchanged.toasthas onlysuccess,error,warning,info,promise,dismiss.toasthas four tones and nothing beyond them.toast.customand toasts with an arbitrary layout, whichsonnerhas, are left out of the kit on purpose: a toast that can do everything stops being part of the system, and half a year later the app has five different toasts. The tone, look and layout belong to the kit rather than to the call site; the caller sets only the content: the message,description(the second line),durationand a singleactionwith a label and a handler. If you need more, it is anAlertor a dialog. The kit does not parse server errors: the caller prepares the text fordescription, for exampletoast.error("Couldn't save", { description: extractErrorMessage(error) }).StatusBadge: a non-interactivespanwithtone,sizeand an optional status dot; use a clear text label.
Accessibility and semantics
- The
dangertone onAlertandBannerinterrupts the screen reader's speech; do not set it for ordinary success. Banneris not sticky, and the header below it stays attop: 0: the--topbar-hcontract (ADR-0016) is left untouched. The analysis is in ADR-0027.ProgressandSpinnermust have a name, or a meaningful default.- Sources:
src/components/actions/Alert.tsx,src/components/actions/Progress.tsx,src/components/actions/Spinner.tsx,src/components/actions/Toaster.tsx,src/components/actions/StatusBadge.tsx; the stories of the same components.
TypeScript types
AlertProps
Prop
Type
Plus DOM attributes, such as onChange, onClick, className — 277 in total; the table does not repeat them.
BannerProps
Prop
Type
Plus DOM attributes, such as onChange, onClick, className — 277 in total; the table does not repeat them.
ProgressProps
Prop
Type
SpinnerProps
Prop
Type
ToasterProps
Prop
Type
StatusBadgeProps
Prop
Type
Plus DOM attributes, such as onChange, onClick, className — 278 in total; the table does not repeat them.