On this page
@addTagHelper *, Webority.Ui.RazorTones
Pick the tone by what the message means: info for notices, success for confirmations, danger for errors.
In context
Place a danger alert above the fields when a form fails, saying what failed and what to do next.
Heading and icon
Give the alert a title line for a headline, and an icon to reinforce the tone at a glance.
Custom image
Show a product logo or brand mark in the badge instead of the tone's glyph.
Dismissible
Use a close button only for a notice the reader can acknowledge once, never for an error that must stay.
Borderless
Drop the soft ring when the alert sits inside a bordered card or a dense layout.
Explanatory asides
Explain how a figure is worked out with a quiet aside that screen readers do not interrupt.
Long text
A long message wraps onto as many lines as it needs, inside the alert.
Every option
Every value of every prop, one cell each.
tone: all five
tone="info" (default)
tone="success"
tone="warning"
tone="danger"
tone="neutral"
title & icon
(default): no title, the tone's glyphtitle onlyicon onlytitle + iconicon="none": no badgeicon: a node icon is React-only; Razor takes a library icon nameicon-variant: the six iconsax styles
icon-variant="linear" (default)
icon-variant="outline"
icon-variant="bold"
icon-variant="bulk"
icon-variant="broken"
icon-variant="twotone"
icon-size: the badge glyph in px
(default) follows sizeicon-size="16"icon-size="28"image, image-alt and image-size
(default): no picture, the tone's glyphimage="url": a picture fills the badgeimage-alt="Acme": alt text, read aloud, not shownimage-size="48": the picture badge in pxdismissible and onClose
(default): not dismissibledismissible="true": the × shows and closes the alert on clickonClose: React only, a callback run on the × clickdismissible="false": suppresses the buttondismissible + icon + titlebordered
bordered (default): the soft ring of the tonebordered="false": tint fill onlyaccent
(default): no left edgeaccent="true": a thick left edge in the tone coloursize
size="sm": a compact single linesize="md" (default)size="lg": roomier heading, body and badgeaction
<app-alert-action>: a trailing action pinned rightrole
(default) role="alert"role="status"role="none": explanatory content, not announcedclassName
className: React only; Razor takes a plain class attributecontent: long text, no width cap
long body: wraps within the alert, no overflow
Guidance
What to do, and what to avoid.
Use it when
- A message needs to persist on the page while its cause is true: a form error, a trial warning.
- You are stating status inline, in context, next to the thing it concerns.
- The user should be able to re-read it. It is not a fleeting confirmation.
- You are explaining how something works, as page content (accent with role "none").
Reach for something else when
- The feedback is brief and self-dismissing, such as "Saved" or "Copied". → toast
- It is a small count or a one-word label. → AppBadge
- It maps a status enum to a coloured pill. → AppStatusBadge
- It is a help hint tied to a single field label. → AppInfoTip
Match the tone to the message
Match the tone to intent and say what to do next. A danger alert names the problem and the recovery.
A success (green) tone on an error message contradicts the words. The colour lies about what happened.
Use info for a neutral notice
A neutral, informational notice uses the info tone: calm, not alarming.
A warning (amber) tone on a purely informational message implies a problem that is not there.
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
15 props. The 5 most used come first.
Used on most screens 5 props
| Prop | Type | Default | Description |
|---|---|---|---|
| tonedefault info | info | success | warning | danger | neutral | info | The status tone. Neutral is a plain notice in ink on a grey surface, with no semantic colour. |
| titledefault - | string | - | A bold heading line above the body. |
| icondefault - | string | - | A leading glyph, given as a semantic icon name. It defaults to the glyph of the tone; pass null for no badge. |
| dismissibledefault false | bool | false | Shows the close button. It is on by default when a close handler is set. |
| sizedefault md | sm | md | lg | md | Sm is a compact single line. Lg is roomier, with a larger heading, body and badge. |
Less common 10 props
| Prop | Type | Default | Description |
|---|---|---|---|
| (content)default - | string | - | The alert message (inner content). |
| icon-variantdefault linear | linear | outline | bold | bulk | broken | twotone | linear | The iconsax style of a named icon. It does not change an image. |
| icon-sizedefault - | int | - | The badge glyph's width and height in px. Unset, it follows size. |
| imagedefault - | string | - | A custom image URL shown in the badge instead of the icon glyph. |
| image-altdefault '' | string | '' | Alt text for the custom image. |
| image-sizedefault - | int | - | Width and height of the image badge in px. Unset, it follows size. |
| roledefault alert | alert | status | none | alert | Status is for notices that must not interrupt a screen reader. None is for explanatory page content. |
| bordereddefault true | bool | true | Draws the soft border of the tone. False keeps only the tint fill. |
| accentdefault false | bool | false | A thick left edge in the tone colour, marking the alert as an aside. |
| <app-alert-action>default - | child | - | A trailing action pinned to the right, usually an <app-button>. It drops below the text on phones. |
Screen reader
3 notes- The alert role is set by default, so assistive technology announces the alert as it appears; pass status for a notice that must not interrupt.
- Role none removes the role, so an explanatory note reads as ordinary page content.
- A custom image takes its alt text from imageAlt, which is empty by default.
Do and avoid
2 pairsMatch the tone to the message
Match the tone to intent and say what to do next. A danger alert names the problem and the recovery.
A success (green) tone on an error message contradicts the words. The colour lies about what happened.
Use info for a neutral notice
A neutral, informational notice uses the info tone: calm, not alarming.
A warning (amber) tone on a purely informational message implies a problem that is not there.