ComponentStandalone

Alert

Inline status banner — info, success, warning, danger, neutral, offline.

Installation

import { WrAlert } from 'ngwr/alert';

@Component({ imports: [WrAlert] })
export class MyComponent {}

Basic usage

Heads up

Your trial ends in 3 days.

<wr-alert title="Heads up" message="Your trial ends in 3 days." />

Types

info

Sample message

success

Sample message

warning

Sample message

danger

Sample message

neutral

Sample message

offline

Sample message

<wr-alert title="Info" type="info" />
<wr-alert title="Success" type="success" />
<wr-alert title="Warning" type="warning" />
<wr-alert title="Danger" type="danger" />
<wr-alert title="Neutral" type="neutral" />
<wr-alert title="Offline" type="offline" />

With title

Pair a title with a secondary message.

Update available

Version 2.0 is ready to install.

<wr-alert title="Update available" message="Version 2.0 is ready to install." type="info" />

Without title

Omit title and the message renders as a single primary line.

Your changes are live.

Connection lost.

<wr-alert message="Your changes are live." type="success" />
<wr-alert message="Connection lost." type="offline" />

Custom icon

Override the default per-type icon with iconName.

What's new

Smarter search just landed.

<wr-alert iconName="sparkles" title="What's new" message="Smarter search just landed." />

Closable

Saved

Your changes are live.

<wr-alert title="Saved" type="success" closable (closed)="onClose()" />

Without icon

Pass [icon]="false" to suppress the leading status icon.

Plain

No leading icon.

<wr-alert title="Plain" message="No leading icon." [icon]="false" />

API

NameDescriptionTypeDefault
closeLabelAccessible name. Falls back to alert.close, then 'Close alert'.string | nullnull
titleOptional headline shown at the top of the alert.string | nullnull
typeVisual variant.WrAlertType'info'
iconNameOverride the default per-type icon with any ngwr icon name.WrIconName | nullnull
messageOptional secondary message rendered below the title.string | nullnull
iconWhen true, renders a leading status icon matching the type. Pass false to hide. Ignored when iconName is set.booleantrue
closableWhen true, renders a close button.booleanfalse
(closed)Emitted when the user dismisses the alert via the close button.void

CSS variables

Custom properties ngwr/alert publishes. Each default below is declared on the component's own selector, so a :root override is shadowed by it — set them on that selector, on a wrapper you scope yourself, or inline on the element. Unlike the BEM class names, these are the supported way to restyle the component.

VariableDefaultDeclared on
--wr-alert-bgvar(--wr-color-info-soft).wr-alert +3 variant overrides
--wr-alert-bordertransparent.wr-alert
--wr-alert-closevar(--wr-color-info).wr-alert +3 variant overrides
--wr-alert-messagevar(--wr-color-on-surface).wr-alert +2 variant overrides
--wr-alert-titlevar(--wr-color-info-ink).wr-alert +3 variant overrides