
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
@spectrum-web-components/dialog
Advanced tools
`sp-dialog` displays important information that users need to acknowledge. They appear over the interface and block further interactions. When used directly the `sp-dialog` element surfaces a `slot` based API for deep customization of the content to be in
sp-dialog
displays important information that users need to acknowledge. They appear over the interface and block further interactions. When used directly the sp-dialog
element surfaces a slot
based API for deep customization of the content to be included in the overlay.
Note: the sp-dialog
element is a component that is used to create a dialog layout. For modal and popover behavior, it should be used within a component that manages the overlay state.
yarn add @spectrum-web-components/dialog
Import the side effectful registration of <sp-dialog>
via:
import '@spectrum-web-components/dialog/sp-dialog.js';
When looking to leverage the Dialog
base class as a type and/or for extension purposes, do so via:
import { Dialog } from '@spectrum-web-components/dialog';
The dialog consists of several key parts:
slot="heading"
)slot="hero"
)slot="button"
)slot="footer"
)dismissable
attribute)<sp-dialog size="s">
<div
slot="hero"
style="background-image: url(https://picsum.photos/1400/260)"
></div>
<h2 slot="heading">Disclaimer</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
<div slot="footer">Footer information</div>
<sp-button slot="button">Button</sp-button>
</sp-dialog>
<sp-dialog size="s">
<h2 slot="heading">Disclaimer</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam
in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra
nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo
duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus
nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem
ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu
mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper
dignissim cras lobortis.
</sp-dialog>
Medium
<sp-dialog size="m">
<h2 slot="heading">Disclaimer</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam
in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra
nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo
duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus
nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem
ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu
mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper
dignissim cras lobortis.
</sp-dialog>
Large
<sp-dialog size="l">
<h2 slot="heading">Disclaimer</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam
in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra
nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo
duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus
nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem
ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu
mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper
dignissim cras lobortis.
</sp-dialog>
When supplied with the dissmissable
attribute an <sp-dialog>
element will surface a "close" button afordance that will dispatch a DOM event with the name of close
when pressed.
Note: the dissmissable
attribute will not be followed when mode="fullscreen"
or mode="fullscreenTakeover"
are applies in accordance with the Spectrum specification.
<sp-dialog dismissable>
<h2 slot="heading">Disclaimer</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam
in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra
nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo
duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus
nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem
ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu
mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper
dignissim cras lobortis.
</sp-dialog>
<sp-dialog dismissable no-divider>
<h2 slot="heading">Disclaimer</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris
augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam
in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra
nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo
duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus
nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem
ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu
mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper
dignissim cras lobortis.
</sp-dialog>
Use the dialog with an overlay to create a dialog that appears over the current page. The dialog manages several behaviors:
<sp-button id="trigger">Overlay Trigger</sp-button>
<sp-overlay trigger="trigger@click" placement="bottom">
<sp-popover>
<sp-dialog>
<h2 slot="heading">Overlay 1</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor
augue mauris augue neque gravida. Libero volutpat sed ornare arcu.
</sp-dialog>
</sp-popover>
</sp-overlay>
<overlay-trigger placement="top" type="replace">
<sp-button slot="trigger">Overlay Trigger 2</sp-button>
<sp-popover slot="click-content" open>
<sp-dialog size="s">
<h2 slot="heading">Overlay 2</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor
augue mauris augue neque gravida. Libero volutpat sed ornare arcu.
<sp-button
slot="button"
onclick="javascript: this.dispatchEvent(new Event('close', {bubbles: true, composed: true}));"
>
I understand
</sp-button>
</sp-dialog>
</sp-popover>
</overlay-trigger>
The receives-focus
attribute can be used to control whether the dialog should receive focus when it is opened. Leverage the type="modal"
and receives-focus="auto"
settings in the Overlay API to ensure that focus is thrown into the dialog content when opened and that the tab order will be trapped within it while open.
The receives-focus
attribute on overlay-trigger
has three possible values:
auto
(default): Focus will automatically move to the first focusable element in the dialogtrue
: Forces focus to move to the overlay contentfalse
: Prevents focus from moving to the overlayFor accessible dialogs, always use receives-focus="auto"
or receives-focus="true"
to ensure keyboard users can interact with the dialog content.
<sp-button id="focus">Overlay Trigger</sp-button>
<sp-overlay trigger="focus@click" type="modal" receives-focus="auto">
<sp-popover>
<sp-dialog>
<h2 slot="heading">Dialog Heading</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor
augue mauris augue neque gravida. Libero volutpat sed ornare arcu.
</sp-dialog>
</sp-popover>
</sp-overlay>
The heading
slot is of the sp-dialog
dialog element is used to label the dialog content for screen readers.
1.7.0 (2025-06-11)
sp-overlay: Fixed : Overlays (like pickers and action menus) were incorrectly closing when scrolling occurred within components. The fix ensures the handleScroll
method in OverlayStack
only responds to document/body scrolling events and ignores component-level scrolling events, which was the original intention.
sp-card: Fixed: On mobile Chrome (both Android and iOS), scrolling on sp-card
components would inadvertently trigger click events. This was caused by the timing-based click detection (200ms threshold) in the pointer event handling, which could misinterpret quick scrolls as clicks. This issue did not affect Safari on mobile devices.
sp-action-button: - Fixed : Action buttons with href attributes now properly detects modifier keys and skips the proxy click, allowing only native browser behavior to proceed.
sp-styles: Remove unnecessary system theme references to reduce complexity for components that don't need the additional mapping layer.
sp-card: - Fixed: sp-card
component relies on sp-popover
for certain toggle interactive behaviors, but this dependency was missing from its dependency tree.
sp-menu: Fixes: Icons in menu stories weren't properly responding to theme changes when used in functional story components. Switching to class-based LitElement components ensures proper component lifecycle hooks and shadow DOM context for icon initialization and theme integration.
sp-tabs: Added @spectrum-web-components/action-button
as a dependency for Tabs as its used in the direction button.
sp-split-view: Added @spectrum-web-components/shared dependency in splitview since it uses ranDomId from the shared package
sp-textfield: Replace deprecated word-break: break-word
with overflow-wrap: break-word
to align with modern CSS standards and improve cross-browser compatibility. This property was deprecated in Chrome 44 (July 2015) in favor of the standardized overflow-wrap
property.
FAQs
`sp-dialog` displays important information that users need to acknowledge. They appear over the interface and block further interactions. When used directly the `sp-dialog` element surfaces a `slot` based API for deep customization of the content to be in
The npm package @spectrum-web-components/dialog receives a total of 2,441 weekly downloads. As such, @spectrum-web-components/dialog popularity was classified as popular.
We found that @spectrum-web-components/dialog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.