- components
- ›
- dialog
- ›
- svelte
Dialog
A modal dialog for displaying content and actions.
Alert Dialog
The alertdialog role enables assistive technologies and browsers to distinguish alert dialogs from other dialogs so they have the option of giving alert dialogs special treatment, such as playing a system alert sound.
Interaction
If desired, you can disable click to close interactions for the backdrop. We recommend using this sparingly, as this traps the user in this experience.
Drawer
This example repurposes the Dialog for use as a side-panel Drawer. It also introduces basic transition animations.
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Nulla, soluta optio assumenda nobis dignissimos minus doloremque in aliquid amet laboriosam! Soluta recusandae facilis provident ratione a! Vitae expedita rerum magni.
Z-Index
By default we do not take an opinionated stance regarding z-index stacking. The result is the component can sometimes be occluded beneath other elements with a higher index. The Z-Index can controlled by applying a utility class to the Positioner
component part.
Direction
Headless
Unlike most components in Skeleton, this feature is provided “headless”. This means no default styles are applied out of the box. This ensures you retain full control of all styling.

The benefits are as follows:
- You can make the
Trigger
surround any element, including an icon, button, image, etc. - You can modify the entire structure within
Content
, including custom markup and styling. - You may place the
CloseTrigger
anywhere, and use it as an X close option.
API Reference
RootProvider
Property | Default | Type |
---|---|---|
value | - | () => DialogApi<PropTypes> |
children | - | Snippet<[]> | undefinedThe default slot content to be rendered within the component. |
Root
Property | Default | Type |
---|---|---|
dir | "ltr" | "ltr" | "rtl" | undefinedThe document's text/writing direction. |
role | "dialog" | "dialog" | "alertdialog" | undefinedThe dialog's role |
aria-label | - | string | undefinedHuman readable label for the dialog, in event the dialog title is not rendered |
ids | - | Partial<{ trigger: string; positioner: string; backdrop: string; content: string; closeTrigger: string; title: string; description: string; }> | undefinedThe ids of the elements in the dialog. Useful for composition. |
trapFocus | true | boolean | undefinedWhether to trap focus inside the dialog when it's opened |
preventScroll | true | boolean | undefinedWhether to prevent scrolling behind the dialog when it's opened |
modal | true | boolean | undefinedWhether to prevent pointer interaction outside the element and hide all content below it |
initialFocusEl | - | (() => MaybeElement) | undefinedElement to receive focus when the dialog is opened |
finalFocusEl | - | (() => MaybeElement) | undefinedElement to receive focus when the dialog is closed |
restoreFocus | - | boolean | undefinedWhether to restore focus to the element that had focus before the dialog was opened |
closeOnInteractOutside | true | boolean | undefinedWhether to close the dialog when the outside is clicked |
closeOnEscape | true | boolean | undefinedWhether to close the dialog when the escape key is pressed |
open | - | boolean | undefinedThe controlled open state of the dialog |
defaultOpen | false | boolean | undefinedThe initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog. |
onOpenChange | - | ((details: OpenChangeDetails) => void) | undefinedFunction to call when the dialog's open state changes |
getRootNode | - | (() => Node | ShadowRoot | Document) | undefinedA root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. |
onEscapeKeyDown | - | ((event: KeyboardEvent) => void) | undefinedFunction called when the escape key is pressed |
onRequestDismiss | - | ((event: LayerDismissEvent) => void) | undefinedFunction called when this layer is closed due to a parent layer being closed |
onPointerDownOutside | - | ((event: PointerDownOutsideEvent) => void) | undefinedFunction called when the pointer is pressed down outside the component |
onFocusOutside | - | ((event: FocusOutsideEvent) => void) | undefinedFunction called when the focus is moved outside the component |
onInteractOutside | - | ((event: InteractOutsideEvent) => void) | undefinedFunction called when an interaction happens outside the component |
persistentElements | - | (() => Element | null)[] | undefinedReturns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event |
children | - | Snippet<[]> | undefinedThe default slot content to be rendered within the component. |
RootContext
Property | Default | Type |
---|---|---|
children | - | Snippet<[() => DialogApi<PropTypes>]> |
Trigger
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"button">]> | undefinedRender the element yourself |
Backdrop
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
Positioner
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
Content
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
Title
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
Description
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
CloseTrigger
Property | Default | Type |
---|---|---|
element | - | Snippet<[HTMLAttributes<"button">]> | undefinedRender the element yourself |