Alert
Alerts display brief messages for the users without interrupting their use of the app.
Alerts give users brief and potentially time-sensitive information in an unobtrusive manner.
Basic Alert
Preview
Usage
import { Alert, AlertTitle, AlertDescription } from 'archi-ui'
<Alert>
<AlertTitle>Alert title</AlertTitle>
<AlertDescription>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut dolores atque ipsa quae incidunt sit aperiam quisquam quis aliquid reiciendis</AlertDescription>
</Alert>
Severity
The severity
prop accepts for values representing different states - success
(default), info
, warning
, and error
- with corresponding icon and color combinations for each.
Preview
Variants
The Alert
component comes with two alternativ style options: filled and outlined.
To set different variants use variant
prop.
Filled
Preview
Outlined
Preview
Alert Title
To add a title to an Alert, import AlertTitle
component
import { AlertTitle } from 'archi-ui'
You can nest this component above the message in your Alert for a neatly styled and properly aligned title, as shown below:
Preview
Success
Info
Warning
Error
Alert Title Variants
AlertTitle
component provides variant
option for different typography styles for Alert Title like h1, h2,…, h6, and other variants to override the root node.
Alternatively, you can use the component
prop to override root node. Either a string to use a HTML element or a component.
Preview
H1 Heading
H2 Heading
h3 Heading
P Component
Alert Actions
Add an action to your Alert with the action
prop. This lets you insert any element - an HTML tag, an SVG icon, or a React component such as a Button - After the Alert’s message, justify to the right.
If you provide an onClose
callback to the Alert without setting the action
prop, the component will display a close icon(X) by default.
Preview
Icons
Use the icon
prop to override an Alert’s icon. As with the action
prop, your icon
can be an HTML element, an SVG icon, or a React component. Set this prop to false
to remove the icon altogether.
Preview
Icon Mapping
If you need to override all instances of an icon for a given severity, you can use the iconMapping prop instead.
Preview
Alert API
API reference docs for the React Alert component.
Props
Name | Type | Default | Description |
---|---|---|---|
children | node | - | The content of the component. |
className | string | - | Override or extend the styles applied to the component |
variant | 'filled' | 'outlined' | 'standard' | 'standard' | The variant to use. |
Severity | 'success' | 'info' | 'warning' | 'error' | 'success' | The severity of the alert. This defines the color and icon used. |
action | node | - | The action to display. It renders after the message, at the end of the alert. |
icon | node | - | Override the icon displayed before the children. Unless provided, the icon is mapped to the vlue of the severity prop. Set to false to remove the icon. |
iconMapping | {success?: node, info?: node, warning?: node, error?: node } | - | The component maps the severity prop to a range of different icons, for instance success to <CircleCheckBig /> . If you wish to change this mapping, you can provide your own. Alternatively, you can use the icon prop to override the icon displayed. |
onClose | func | - | Callback fired when the component requests to be closed. When provided and no action prop is set, a close icon button is displayed that triggers the callback when clicked. Signature: finction() => void |
role | string | alert | The aria role attribute of the element. |
AlertTitle API
API reference docs for the React AlertTitle component.
Props
Name | Type | Default | Description |
---|---|---|---|
children | node | - | The content of the component. |
className | string | - | Override or extend the styles applied to the component |
variant | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'body1' | 'body2' | 'subtitle1' | 'subtitle2' | 'caption' | 'h6' | Applies the typography styles. |
gutterBottom | bool | false | If true , margin 2 from bottom be applied. |
component | elementType | - | The component used for the root node. Either a string to use a HTML element or a component. |
AlertDescription API
API reference docs for the React AlertDescription component.
Props
Name | Type | Default | Description |
---|---|---|---|
children | node | - | The content of the component. |
className | string | - | Override or extend the styles applied to the component |