Check the code in the below repo for the modal implementation in LWC:
https://github.com/iamsonal/lwc-modal
Notes:
- If you want to hide the close icon, then set the
hide-close
property totrue
like below:
<!-- modalContainer.html -->
<template>
<c-modal name="Modal Name" title="Modal Title" hide-close>
</c-modal>
</template>
- Similarly, if you want to display a large modal, then set the
is-large
property totrue
like below:
<!-- modalContainer.html -->
<template>
<c-modal name="Modal Name" title="Modal Title" hide-close is-large>
</c-modal>
</template>
<c-modal name="Modal Name" title="Modal Title" >
<!-- Unnamed Slot -->
<p>This is some content</p>
<!-- Named Slot -->
<div slot="footer" style="display: inline;">
<lightning-button label="Close" variant="neutral" onclick={handleCancelModal}></lightning-button>
</div>
</c-modal>
style-class
property to apply a custom CSS in the modal.