EnModal
Preview
Props
| Name | Description | Default | Control |
|---|---|---|---|
| qaId | Id that can be set for automation selectors. string | "" | |
| title | Sets the title in the modal header. string | "" | |
| size | The width of the modal. string | "md" | |
| showFooter | Renders the modal footer and footer slot. boolean | true | |
| showHeader | Renders the modal header and header slot. boolean | true | |
| showSuccessBtn | Shows the success button in the footer. boolean | true | |
| canClose | Allows the modal to be closed using the close buttons. boolean | true | |
| showModal | Displays the modal. Should be controlled outside of the modal component. boolean | false | |
| closeOnClickOutside | Prevents modal from closing when clicking outside of the modal. boolean | true | |
| modalContentElement | Changes the container element of the modal content. string | "div" | |
| btnSuccessText | Sets text for the success button. string | "Save" | |
| btnCancelText | Sets text for the cancel button. string | "Cancel" | |
| bodyScroll | Applies a scrollbar to the body of the modal when the content gets too long. boolean | false | |
| trapFocus | Locks Tab navigation inside the modal while it is open. Tab order follows DOM order: header → body → footer, then wraps. Restores focus to the previously-focused element on close. boolean | true |
Slots
header
Replaces the `modal-title` div.
title
Sets the content inside the `modal-title` div.
header-right
Adds content to the right of the title in the modal header, alongside the close button. Additive: it does not replace the close button, so a modal using it keeps its dismiss control.
content
Replaces both the `modal-body` and `modal-footer` divs.
body
Sets the content inside the `modal-body` div.
footer
Replaces the buttons inside the `modal-footer` div.
Events
close
Fires when the modal closes. Should be used to set the `showModal` prop back to false if used.
open
Fires when the modal opens.
save
This is triggered with the default save button. Emits save event with the close modal method as an arg.
Payload
| Name | Type | Description |
|---|---|---|
closeModal | function | function that will close the modal if called. |
Methods
No methods defined.
Examples
Using Props
header-right places content to the right of the title, alongside the close button rather than replacing it — so a modal using it keeps its dismiss control. Use it for a status the header should carry (a chip, a record count, a step indicator), not for actions; those belong in the footer.
Contrast it with the header slot, which replaces the title block entirely and leaves you responsible for the heading.
Filling the slot turns the header into a flex row that wraps on a narrow screen, with the title taking the free space and the close button staying at the far end. Modals without the slot keep the plain block header. A heading you render through the header slot is laid out the same way, so it needs no margin or media query of its own.
Closing a modal that the user cannot dismiss
canClose withholds the close button, the backdrop click and Escape from the user. It does not stop the owner of showModal: setting that prop false closes the modal regardless, so a modal guarded with :can-close="allAnswered" can still be closed by the code that opened it after its own save. The close event fires either way.
The save event hands you the close method as its argument. It honors canClose too, so a modal that saves before it can be dismissed should flip showModal rather than call the method it was given.
Form in the modal, confirm disabled until valid
Put an EnForm with in-modal in the content slot. That slot replaces the modal's body and footer, and inModal makes the form render both itself, so the fields land in the body and the buttons in the footer. The form's buttons slot exposes meta, its live validation state: bind :disabled="!meta.valid" on EnButtonSubmit and the confirm button stays disabled until the form is valid. The user cannot confirm until every required field is filled in correctly, and Cancel stays available throughout. For a gate that is not the form's own validity, such as unsaved changes or an acknowledgement, use the form's disableSubmit prop instead; the EnForm page shows that.
A modal whose body is not an EnForm gets the same result from the footer slot: render your own .btn buttons and bind the native disabled attribute to the condition. showSuccessBtn only shows or hides the default Save button; it cannot disable it.