Skip to main content

Alert

Quick start

Here's a quick start guide to get started with the Alert component

Importing Component

import { Alert } from "@hover-design/react";

Code Snippets and Examples

Alert Info
<div className="App">
<Alert title="Info">This is an Info Alert</Alert>
</div>
Alert Success
<div className="App">
<Alert title="Success" type="success">
This is a Success Alert
</Alert>
</div>
Alert Warning
<div className="App">
<Alert title="Warning" type="warning">
This is a Warning Alert
</Alert>
</div>
Alert Danger
<div className="App">
<Alert title="Danger" type="danger">
This is a Danger Alert
</Alert>
</div>
Alert Variant - Filled
<div className="App">
<Alert title="Filled Alert" variant="filled">
This is a Filled Alert
</Alert>
</div>
Alert Variant - Outline
<div className="App">
<Alert title="Outline Alert" variant="outline">
This is an Outline Alert
</Alert>
</div>
Alert - Custom Colors
<Alert title="Custom Colors" color="hotpink" backgroundColor="lavenderblush">
This is a Customized Alert
</Alert>
Alert - with Close Button
<div className="App">
<Alert title="Close Button" withCloseButton>
This alert has a Close Button
</Alert>
</div>

Note: Clicking on the close button triggers the onClose function which should be passed as a prop to the component

Props Reference

AttributesValuesDefault ValueOptional ?
variantlight | filled | outlinelightYes
typeinfo | success | warning| dangerinfoYes
titleReactNodeYes
iconReactNodeYes
colorstringYes
borderRadiusstring4pxYes
backgroundColorstringYes
closeButtonLabelaria-label for close button:
string
Yes
withCloseButtonbooleanfalseYes
onCloseis triggered when the close button is clicked
()=>void
Yes

Custom Styles

Note: It is advised to use these classNames scoped inside of the className given as prop to the main component.

ClassNameElement
hover-alert-titleTitle container
hover-alert-descriptionDescription Container
hover-alert-closeButtonIconClose Button Icon Container
hover-alert-iconIcon Container