Skip to main content

Alert

v.5.0.1

Installation

yarn add @mercell/alert-react

Usage

Using the Alert component is as simple as importing it like this.

import { Alert, AlertText, AlertTitle } from '@mercell/alert-react';
Live Editor
Result

Types, definitions, etc.

AlertProps
interface AlertProps {
iconProps?: CarbonIconProps;
scheme: FunctionScheme;
timeout?: number;
closeAlertCallback?: () => void;
role: JSX.IntrinsicElements['div']['role'];
} & JSX.IntrinsicElements['div']
NameTypeDefaultRequiredDescription
iconPropsCarbonIconProps-yesall possible properties allowed by CarbonIconProps
schemeFunctionScheme-yesScheme to select the color of the alert
timeoutnumber-noTime in ms to close the alert automatically. Ex. set to 5000 to automatically close after 5 seconds
closeAlertCallbackfunction-noWhat to trigger in the close buttons onClick
roleJSX.IntrinsicElements['div']['role']-yesSetting up role for accessibility based on 'role' props for 'div' tag
AlertTitleProps
AlertTitle has JSX.IntrinsicElements['h3'] type
AlertTextProps
AlertText has JSX.IntrinsicElements['div'] type
FunctionScheme
type FunctionScheme<T = ''> =
| 'information'
| 'success'
| 'error'
| 'important'
| 'default'
| T;
NameTypeDefaultRequiredDescription
FunctionScheme'information' | 'success' | 'error' | 'important' | T--Scheme to select the color of the alert