| Name | Type | Description | Default |
|---|---|---|---|
| closable | boolean | If true, the alert will have a close button that will call the onClose. | true |
| message | Message | Message[]being {
onClose?: () => void;
text: React.ReactNode;
} | List of messages to be displayed. Each message has a close action that will call the onClose if it is defined. If the message is an array, the alert will show a navigation bar to move between the messages. The modal mode only allows one message per alert. In this case, the message must be an object and the presence of the onClose attribute is mandatory, since the management of the closing of the alert relies completely on the user. | - |
| mode | 'inline' | 'modal' | 'banner' | The mode of the alert. The possible values are:
| 'inline' |
| primaryAction | {
icon?: string | (React.ReactNode
& React.SVGProps<SVGSVGElement>);
label: string;
onClick: () => void;
} | Primary action of the alert. | - |
| secondaryAction | {
icon?: string | (React.ReactNode
& React.SVGProps<SVGSVGElement>);
label: string;
onClick: () => void;
} | Secondary action of the alert. | - |
| semantic | 'error' | 'info' | 'success' | 'warning' | Specifies the semantic meaning of the alert. | 'info' |
Required title | string | Title of the alert. | - |
() => { return ( <DxcInset space="var(--spacing-padding-xl)"> <DxcFlex direction="column" gap="var(--spacing-gap-l)"> <DxcAlert title="Auto-saved document" message={{ text: "Your document as been auto-saved. You can continue working without worry, as all changes are being saved automatically." }} /> <DxcAlert title="Read carefully" semantic="warning" message={{ text: "Please read the documents carefully before the submission of the data." }} /> <DxcAlert title="Save failed" semantic="error" message={{ text: "You have unsaved changes in your document. If you navigate away from this page, you will lose any changes you have made." }} /> <DxcAlert title="Saved successfully" semantic="success" message={{ text: "Your document has been saved successfully." }} /> </DxcFlex> </DxcInset> ); }
() => { const [messages, setMessages] = useState([ { text: "Your document as been auto-saved.", onClose: () => { setMessages((prevMessages) => prevMessages.filter(({ text }) => text !== "Your document as been auto-saved.")); }, }, { text: "You can continue working without worrying, as all changes are automatically saved.", onClose: () => { setMessages((prevMessages) => prevMessages.filter( ({ text }) => text !== "You can continue working without worrying, as all changes are automatically saved." ) ); }, }, { text: "You can also go back to the previous version of the document.", onClose: () => { setMessages((prevMessages) => prevMessages.filter(({ text }) => text !== "You can also go back to the previous version of the document.") ); }, }, ]); return ( <DxcInset space="var(--spacing-padding-xl)"> <DxcFlex direction="column" gap="var(--spacing-gap-l)"> <DxcAlert title="Auto-saved document" message={messages} primaryAction={{ label: "Continue", onClick: () => {} }} secondaryAction={{ label: "Back", onClick: () => {} }} /> </DxcFlex> </DxcInset> ); }