Skip to main content

Alert

Alert component can be used to display alerts, notifications and other feedback messages to the user

You have earned a million dollars!
No. Just kidding.

Basic Usage

import React from 'react';
import { Alert } from 'chic-ui';

<>
<Alert
title="You have earned a million dollars!"
message="No. Just kidding."
/>
</>;

Types of Alert

Use the type prop to specify the type of alert. Default type is primary

Title
Message
Title
Message
Title
Message
Title
Message
Title
Message
Title
Message
Title
Message
import React from 'react';
import { Alert } from 'chic-ui';

<>
<Alert title="Title" message="Message" type="primary" />
<Alert title="Title" message="Message" type="secondary" />
<Alert title="Title" message="Message" type="warning" />
<Alert title="Title" message="Message" type="success" />
<Alert title="Title" message="Message" type="danger" />
<Alert title="Title" message="Message" type="info" />
<Alert title="Title" message="Message" type="light" />
<>
</>;

Dismiss Alerts

An alert can be dismissed by setting dismissible prop to true. The onClose prop specifies a function that will be called when the alert is dismissed

Title
message
import { Alert } from 'chic-ui';
export function DismissAlerts(){
const [show, setShow] = React.useState(true);

const onClick = useCallback(() => {
setShow((prev) => !prev);
}, []);

return (
<Alert
title={'Title'}
message={'message'}
dismissible
type="primary"
show={show}
onClose={onClick}
/>
);
};

API

import { Alert } from 'chic-ui';
NameTypeDefaultDescription
type'primary' | 'secondary' | 'danger' | 'warning' | 'success' | 'info' | 'light''primary'Type of alert
title (required)stringTitle of the alert
message (required)stringMessage of the alert
dismissiblebooleanfalseBoolean flag to allow dismissing the alert
showbooleantrueBoolean flag to show the alert
onClosefunctionSpecify a function that will be called when the message is closed
classNamestringProvide external classnames to the component
styleReact.CSSPropertiesOverride default styling of the component