eds-modal
Explore the Interactive Component
Use the playground below to experiment with the component. Click the button to view the full Storybook deployment for additional examples and configurations.
See It in Use with Code
Check out this practical implementation of component.
Anything you place inside <eds-modal> is rendered in its default slot as the modal body. Open and close it with the open(), close() and toggle() methods; it emits edsopen and edsclose.
Plain HTML
In React
In Vue
Sizes and Position
size | Width | Use for |
|---|---|---|
small | 500px | Confirmations, short messages |
medium | 700px (default) | Forms, detailed content |
large | 900px | Complex layouts, tables |
position is middle (default), top or bottom on larger screens. On phones the modal is always full width at the top. Put actions in slot="footer": secondary first, primary last.
Overview
EdsModal is a dialog for focused tasks and messages, built on the native
<dialog> element (showModal()), so the browser keeps keyboard and
screen-reader focus inside it and makes the page behind inert.
- Light header with title, optional subtitle and a close button
(
inverse-headerfor the brand-black header). - Body scrolls; an optional
footerslot stays pinned at the bottom. - Closes on Escape, the close button or a click on the backdrop, unless
dismissibleis false (for flows that must be finished or cancelled with an explicit action). - Open it with
open()/toggle(), theopenedprop, or theeds-modal-openevent; it returns focus to where it was on close. - On phones it is full width, anchored to the top.
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
dismissible | dismissible | Whether the user can dismiss the modal with Escape, the close button or a click on the backdrop. Set to false when the modal must be finished or cancelled with an explicit action in its content or footer; the close button is then hidden. | boolean | true |
heading | title | The title of the modal. Names the dialog for assistive technology. | string | '' |
initialFocus | initial-focus | CSS selector of the element to focus when the modal opens, looked up in the modal’s content (e.g. #email). Defaults to the first focusable element in the content, then the close button. | string | undefined |
inverseHeader | inverse-header | Brand-black header with light text instead of the default light header. | boolean | false |
opened | opened | Declarative open state: set it to open or close the modal. Kept in sync when the modal opens or closes by other means (reflected as the opened attribute). open(), close() and toggle() still work. | boolean | false |
position | position | Where the modal sits on larger screens: "middle" (default), "top" or "bottom". On phones it is always full width at the top. | "bottom" | "middle" | "top" | 'middle' |
size | size | Width of the modal (it keeps this width while its content loads): "small" 500px, "medium" 700px (default), "large" 900px — never wider than the screen. | "large" | "medium" | "small" | 'medium' |
subtitle | subtitle | Optional secondary line under the title, in lighter text (e.g. a file path or the item the modal is about). Describes the dialog. | string | undefined |
truncate | truncate | The number of lines to truncate the title to. Set to 0 or undefined to disable truncation. | 0 | 1 | 2 | 3 | 4 | undefined |
Events
| Event | Description | Type |
|---|---|---|
edsclose | Emitted when the modal closes, however it was closed — the close button, Escape, the backdrop, close()/toggle(), opened = false or the global eds-modal-close event. Lets a caller discard work started in the modal that was not saved. | CustomEvent<void> |
edsopen | Emitted when the modal opens. | CustomEvent<void> |
Methods
close() => Promise<void>
Closes the modal.
Returns
Type: Promise<void>
open() => Promise<void>
Opens the modal.
Returns
Type: Promise<void>
toggle() => Promise<void>
Toggles the modal open or closed.
Returns
Type: Promise<void>
Dependencies
Depends on
Graph
graph TD; eds-modal --> eds-button eds-button --> eds-icon-wrapper style eds-modal fill:#f9f,stroke:#333,stroke-width:4px
Built with StencilJS