Alert
Show a persistent message inline.
Examples
Show a persistent message inline
Review required
React code
import { Alert, AlertTitle, AlertDescription } from "@accelerate/react/components";
export function Example() {
return (
<>
<Alert data-tone="warning">
<AlertTitle>Review required</AlertTitle>
<AlertDescription>Check the owner before submitting this request.</AlertDescription>
</Alert>
</>
);
}Angular code
import { Component } from "@angular/core";
import {
AccAlert,
AccAlertTitle,
AccAlertDescription,
} from "@accelerate/angular/components";
@Component({
selector: "app-example",
imports: [
AccAlert,
AccAlertTitle,
AccAlertDescription,
],
template: `
<div accAlert data-tone="warning">
<h3 accAlertTitle>Review required</h3>
<div accAlertDescription>Check the owner before submitting this request.</div>
</div>
`,
})
export class Example {}Success and error tones
Draft saved
Save failed
React code
import { Alert, AlertTitle, AlertDescription } from "@accelerate/react/components";
export function Example() {
return (
<>
<Alert data-tone="success">
<AlertTitle>Draft saved</AlertTitle>
</Alert>
<Alert data-tone="error" role="alert">
<AlertTitle>Save failed</AlertTitle>
<AlertDescription>Try saving again.</AlertDescription>
</Alert>
</>
);
}Angular code
import { Component } from "@angular/core";
import {
AccAlert,
AccAlertTitle,
AccAlertDescription,
} from "@accelerate/angular/components";
@Component({
selector: "app-example",
imports: [
AccAlert,
AccAlertTitle,
AccAlertDescription,
],
template: `
<div accAlert data-tone="success">
<h3 accAlertTitle>Draft saved</h3>
</div>
<div accAlert data-tone="error" role="alert">
<h3 accAlertTitle>Save failed</h3>
<div accAlertDescription>Try saving again.</div>
</div>
`,
})
export class Example {}Installation
Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.
- React
@accelerate/ui@0.4.0and@accelerate/react@0.4.0- Angular
@accelerate/ui@0.4.0and@accelerate/angular@0.2.0
Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.
Usage
Use AlertTitle and AlertDescription. Set data-tone to error, warning, or success. Use role="alert" for urgent announcements.
Import the React component Alert from @accelerate/react/components. For Angular, add AccAlert to the standalone component’s imports and use <div accAlert>.
Examples use these React parts: Alert, AlertTitle, AlertDescription. The Angular examples show the corresponding directives and template hosts.
API reference
- data-tone
- Use error, warning, or success to convey the message type.
- role
- Defaults to status. Use alert for time-sensitive announcements.