modal 4.1.2
Install from the command line:
Learn more about npm packages
$ npm install @axa-ch-webhub-cloud/modal@4.1.2
Install via package.json:
"@axa-ch-webhub-cloud/modal": "4.1.2"
About this version
A modal component for custom child elements. Important:
-
z-indexfor the modal is 3000. -
margin-topwill automatically be set to0for the first child element inforcedmode. -
margin-bottomwill automatically be set to0for the last child element inforcedmode.
npm install @axa-ch-webhub-cloud/modalimport '@axa-ch-webhub-cloud/modal';
// ...
<axa-modal></axa-modal>;| Attribute | Details |
|---|---|
open |
State of modal visibility (boolean) |
forced |
Disables the internal close mechanisms (boolean) |
small |
Smaller version of the modal (boolean, default: false) |
noheader |
Removes the header and the space around the modal content (boolean, default: false) |
If open is set to true, then the modal will be displayed to the user.
If forced is set to true, closing functionality has to be manually implemented. This is useful for legal text displayed to the user, where the user has to explicitly "approve" to click the modal away.
If smallis set to true, it has the small size and sets the max-width attribute to 500px.
If noheader is set to true, the modal will be displayed without header and padding of the root element.
Under React we can pass a method onClose that will get called when the Modal closes, like so:
<AXAModal
open
onClose={(customEvent) => {
console.log(customEvent, 'called when modal closes');
}}
/>When using the component as a native WebComponent, you can add an event listener on axa-modal that listens to the custom event axa-close like so:
const modal = document.querySelector('axa-modal');
modal.addEventListener('axa-close', (customEvent) => {
console.log(customEvent, 'called when modal closes');
});