Alert
Alerts are used to communicate important information to the user. They can be used to inform users about service changes, provide feedback to user actions or communicate general information. Alerts should be short, clear and easy to understand. Icons and colour should be used to help convey content and urgency. The alert will expand to the width of the content, up until the width of its parent element, at which point it will wrap.
Installation
npm install @nib-components/alert
Note: You will also need to install the peerDependencies @nib/icons and @nib-components/theme.
Usage
import Alert from '@nib-components/alert';
Interactive demo
<Alert type="warning" variation="soft" title="Important Information about you cover" fullWidth={false}> This is an optional short message with further, actionable information for the user. </Alert>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
type | string | "info" | Can be one of "info", "warning", "error" or "success". |
title | node | The alert title. | |
fullWidth | boolean | false | To set the alert to span the full width of its parent container. Has no effect on banner variation which is always full-width. |
variation | string | loud | The alert variation. Can be one of "loud", "soft" or "banner". |
titleComponent | string | The underlying component of the Alert title. Must be one of h1, h2, h3, h4, h5, h6, div, label, span, header. | |
children | node | The rest of the contents of the alert, — the "message". | |
containerWidth | ResponsiveWidthProp | default | Only affects the banner variation. Others do not have a container. |
Types
Colour and icons are used to help convey the content and urgency of the alert.
Avoid using colour alone as people with visual acuity or colour blindness may skip over this important information. This is why we use icons too.
The type prop provides a number of Alert variations, each conveying a different meaning to the user.
Success
Success! Your cover has now been updated.
Error
Your last name is missing.
We need your last name to locate your policy.
Warning
Not sure of your admission date?
We have some changes coming in on 1 April this year as part of the government reforms which will affect how our eligibility check works.
Information
$750 hospital excess
You can join nib before 1 April on a $250 or $500 excess and increase your excess after 1 April by logging into Online Services.
Variations
There are three variations available for the Alerts: loud, soft and banner.
Loud
The loud variation is used by default and can be seen in the example below. This is most frequently used for system notifications and urgent information that needs to stand out as much as possible.
Be careful!
Mesh components can be dangerous if not handled properly.
Where possible, we recommend using our more modern alert where possible; the soft variation.
Soft
The soft variation should be used for providing contextual information and general notifications.
Be careful!
Mesh components can be dangerous if not handled properly.
Banner
The banner variation is used for displaying full-width alerts that span the entire width of the viewport. This is most frequently used for site-wide notifications.
Scheduled maintenance on 25th Dec
Our website will be down for scheduled maintenance from 1:00 AM to 5:00 AM AEDT.
Alert copy
All alerts should have a title, which should be short and descriptive.
An alert message is optional and if included should also be short and descriptive. An alert message can include links that redirect the user to further information or next steps.
Important Information
This is an optional short message with a link