Dialog
A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
<script setup lang="ts">
import { Dialog } from '@destyler-ui/vue'
</script>
<template>
<Dialog.Root>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Teleport to="body">
<Dialog.Backdrop />
<Dialog.Positioner data-testid="positioner">
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Teleport>
</Dialog.Root>
</template>
import { createPortal } from 'react-dom'
import { Dialog } from '@destyler-ui/react'
export function Basic(props: Dialog.RootProps) {
return (
<Dialog.Root {...props}>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
{createPortal(
<>
<Dialog.Backdrop />
<Dialog.Positioner data-testid="positioner">
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</>,
document.body,
)}
</Dialog.Root>
)
}
import { Dialog } from '@destyler-ui/solid/dialog'
import { Portal } from 'solid-js/web'
export function Basic() {
return (
<Dialog.Root open>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Portal>
</Dialog.Root>
)
}
<script lang="ts">
import type { DialogRootProps } from '@destyler-ui/svelte'
import { portal } from '@destyler-ui/svelte'
import { Dialog } from '@destyler-ui/svelte'
const props: DialogRootProps = $props()
</script>
<Dialog.Root {...props}>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<div use:portal>
<Dialog.Backdrop />
<Dialog.Positioner data-testid="positioner">
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</div>
</Dialog.Root>
Anatomy
Section titled “Anatomy”<script setup lang="ts">import { Dialog } from '@destyler-ui/vue'</script>
<template> <Dialog.Root> <Dialog.Trigger /> <Dialog.Backdrop /> <Dialog.Positioner> <Dialog.Content> <Dialog.Title /> <Dialog.Description /> <Dialog.CloseTrigger /> </Dialog.Content> </Dialog.Positioner> </Dialog.Root></template>import { Dialog } from '@destyler-ui/react'
export default function Basic() { return ( <Dialog.Root> <Dialog.Trigger /> <Dialog.Backdrop /> <Dialog.Positioner> <Dialog.Content> <Dialog.Title /> <Dialog.Description /> <Dialog.CloseTrigger /> </Dialog.Content> </Dialog.Positioner> </Dialog.Root> )}import { Dialog } from '@destyler-ui/solid'
export default function Basic() { return ( <Dialog.Root> <Dialog.Trigger /> <Dialog.Backdrop /> <Dialog.Positioner> <Dialog.Content> <Dialog.Title /> <Dialog.Description /> <Dialog.CloseTrigger /> </Dialog.Content> </Dialog.Positioner> </Dialog.Root> )}<script lang="ts"> import { Dialog, portal } from '@destyler-ui/svelte'</script>
<Dialog.Root> <Dialog.Trigger>Open dialog</Dialog.Trigger> <div use:portal> <Dialog.Backdrop /> <Dialog.Positioner> <Dialog.Content> <Dialog.Title>Dialog title</Dialog.Title> <Dialog.Description>Dialog description</Dialog.Description> <Dialog.CloseTrigger>Close</Dialog.CloseTrigger> </Dialog.Content> </Dialog.Positioner> </div></Dialog.Root>Examples
Section titled “Examples”<script setup lang="ts">
import { Dialog } from '@destyler-ui/vue'
</script>
<template>
<Dialog.Root>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Teleport to="body">
<Dialog.Backdrop />
<Dialog.Positioner data-testid="positioner">
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Teleport>
</Dialog.Root>
</template>
import { createPortal } from 'react-dom'
import { Dialog } from '@destyler-ui/react'
export function Basic(props: Dialog.RootProps) {
return (
<Dialog.Root {...props}>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
{createPortal(
<>
<Dialog.Backdrop />
<Dialog.Positioner data-testid="positioner">
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</>,
document.body,
)}
</Dialog.Root>
)
}
import { Dialog } from '@destyler-ui/solid/dialog'
import { Portal } from 'solid-js/web'
export function Basic() {
return (
<Dialog.Root open>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Portal>
</Dialog.Root>
)
}
<script lang="ts">
import type { DialogRootProps } from '@destyler-ui/svelte'
import { portal } from '@destyler-ui/svelte'
import { Dialog } from '@destyler-ui/svelte'
const props: DialogRootProps = $props()
</script>
<Dialog.Root {...props}>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<div use:portal>
<Dialog.Backdrop />
<Dialog.Positioner data-testid="positioner">
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</div>
</Dialog.Root>
Controlled
Section titled “Controlled”Control the open state of the dialog programmatically.
<script setup lang="ts">
import { Dialog } from '@destyler-ui/vue'
import { ref } from 'vue'
const open = ref(false)
</script>
<template>
<button @click="() => (open = true)">Open Dialog</button>
<Dialog.Root v-model:open="open">
<Teleport to="body">
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Teleport>
</Dialog.Root>
</template>
import { useState } from 'react'
import { createPortal } from 'react-dom'
import { Dialog } from '@destyler-ui/react'
export function Controlled() {
const [open, setOpen] = useState(false)
return (
<>
<button onClick={() => setOpen(true)}>Open Dialog</button>
<Dialog.Root open={open} onOpenChange={({ open }) => setOpen(open)}>
{createPortal(
<>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</>,
document.body,
)}
</Dialog.Root>
</>
)
}
import { Dialog } from '@destyler-ui/solid/dialog'
import { createSignal } from 'solid-js'
import { Portal } from 'solid-js/web'
export function Controlled() {
const [isOpen, setIsOpen] = createSignal(false)
return (
<>
<button type="button" onClick={() => setIsOpen(true)}>
Open Dialog
</button>
<Dialog.Root open={isOpen()} onOpenChange={() => setIsOpen(false)}>
<Portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Portal>
</Dialog.Root>
</>
)
}
<script lang="ts">
import { portal } from '@destyler-ui/svelte'
import { Dialog } from '@destyler-ui/svelte'
let open = $state(false)
</script>
<button onclick={() => open = true}>Open Dialog</button>
<Dialog.Root bind:open>
<div use:portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</div>
</Dialog.Root>
Lazy Mount
Section titled “Lazy Mount”Mount the dialog content lazily when first opened.
<script setup lang="ts">
import { Dialog } from '@destyler-ui/vue'
</script>
<template>
<Dialog.Root lazyMount unmountOnExit>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Dialog.Root>
</template>
import { Dialog } from '@destyler-ui/react'
export function LazyMount() {
return (
<Dialog.Root lazyMount unmountOnExit>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Dialog.Root>
)
}
import { Dialog } from '@destyler-ui/solid/dialog'
export function LazyMount() {
return (
<Dialog.Root lazyMount unmountOnExit>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Dialog.Root>
)
}
<script lang="ts">
import { Dialog } from '@destyler-ui/svelte'
</script>
<Dialog.Root lazyMount unmountOnExit>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Dialog.Root>
Render Function
Section titled “Render Function”Use render function for custom dialog rendering.
<script setup lang="ts">
import { Dialog } from '@destyler-ui/vue'
</script>
<template>
<Dialog.Root>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Teleport to="body">
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Teleport>
<Dialog.Context v-slot="dialog">
<p>Dialog is {{ dialog.open ? 'open' : 'closed' }}</p>
</Dialog.Context>
</Dialog.Root>
</template>
import { createPortal } from 'react-dom'
import { Dialog } from '@destyler-ui/react'
export function RenderFn() {
return (
<Dialog.Root>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
{createPortal(
<>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</>,
document.body,
)}
<Dialog.Context>
{dialog => <p>Dialog is {dialog.open ? 'open' : 'closed'}</p>}
</Dialog.Context>
</Dialog.Root>
)
}
import { Dialog } from '@destyler-ui/solid/dialog'
import { Portal } from 'solid-js/web'
export function RenderFn() {
return (
<Dialog.Root>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Portal>
<Dialog.Context>
{context => <p>Dialog is {context().open ? 'open' : 'closed'}</p>}
</Dialog.Context>
</Dialog.Root>
)
}
<script lang="ts">
import { portal } from '@destyler-ui/svelte'
import { Dialog } from '@destyler-ui/svelte'
</script>
<Dialog.Root>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<div use:portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</div>
<Dialog.Context>
{#snippet children(dialog)}
<p>Dialog is {dialog().open ? 'open' : 'closed'}</p>
{/snippet}
</Dialog.Context>
</Dialog.Root>
Root Provider
Section titled “Root Provider”<script setup lang="ts">
import { Dialog, useDialog } from '@destyler-ui/vue'
const dialog = useDialog()
</script>
<template>
<button @click="dialog.setOpen(true)">Open</button>
<Dialog.RootProvider :value="dialog">
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Teleport to="body">
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Teleport>
</Dialog.RootProvider>
</template>
import { createPortal } from 'react-dom'
import { Dialog, useDialog } from '@destyler-ui/react'
export function RootProvider() {
const dialog = useDialog()
return (
<>
<button onClick={() => dialog.setOpen(true)}>Open</button>
<Dialog.RootProvider value={dialog}>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
{createPortal(
<>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</>,
document.body,
)}
</Dialog.RootProvider>
</>
)
}
import { Dialog, useDialog } from '@destyler-ui/solid/dialog'
import { Portal } from 'solid-js/web'
export function RootProvider() {
const dialog = useDialog()
return (
<>
<button onClick={() => dialog().setOpen(true)}>Open</button>
<Dialog.RootProvider value={dialog}>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</Portal>
</Dialog.RootProvider>
</>
)
}
<script lang="ts">
import { portal } from '@destyler-ui/svelte'
import { Dialog, useDialog } from '@destyler-ui/svelte'
const id = $props.id()
const dialog = useDialog({ id })
</script>
<button onclick={() => dialog().setOpen(true)}>Open</button>
<Dialog.RootProvider value={dialog}>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<div use:portal>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content>
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Dialog Description</Dialog.Description>
<Dialog.CloseTrigger>Close</Dialog.CloseTrigger>
</Dialog.Content>
</Dialog.Positioner>
</div>
</Dialog.RootProvider>
API Reference
Section titled “API Reference”Root
| Prop | Default | Type |
|---|---|---|
aria-label | — | stringHuman readable label for the dialog, in event the dialog title is not rendered |
closeOnEscape | true | false | trueWhether to close the dialog when the escape key is pressed |
closeOnInteractOutside | true | false | trueWhether to close the dialog when the outside is clicked |
defaultOpen | — | false | trueThe initial open state of the dialog when it is first rendered. Use when you do not need to control its open state. |
finalFocusEl | — | () => HTMLElementElement to receive focus when the dialog is closed |
id | — | stringThe unique identifier of the machine. |
ids | — | Partial<{ trigger: string; positioner: string; backdrop: string; content: string; closeTrigger: string; title: string; description: string; }>The ids of the elements in the dialog. Useful for composition. |
initialFocusEl | — | () => HTMLElementElement to receive focus when the dialog is opened |
lazyMount | false | false | trueWhether to enable lazy mounting |
modal | true | false | trueWhether to prevent pointer interaction outside the element and hide all content below it |
open | — | false | trueWhether the dialog is open |
persistentElements | — | (() => Element)[]Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event |
preventScroll | true | false | trueWhether to prevent scrolling behind the dialog when it's opened |
restoreFocus | — | false | trueWhether to restore focus to the element that had focus before the dialog was opened |
role | "dialog" | "dialog" | "alertdialog"The dialog's role |
trapFocus | true | false | trueWhether to trap focus inside the dialog when it's opened |
unmountOnExit | false | false | trueWhether to unmount on exit. |
| Emit | Event |
|---|---|
escapeKeyDown | [event: KeyboardEvent]Function called when the escape key is pressed |
focusOutside | [event: FocusOutsideEvent]Function called when the focus is moved outside the component |
interactOutside | [event: InteractOutsideEvent]Function called when an interaction happens outside the component |
openChange | [details: OpenChangeDetails]Callback to be invoked when the dialog is opened or closed |
pointerDownOutside | [event: PointerDownOutsideEvent]Function called when the pointer is pressed down outside the component |
update:open | [open: boolean] |
Backdrop
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
CloseTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Context
No serializable props or emits are declared for this part.
Description
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | MachineApi<PropTypes> |
lazyMount | false | false | trueWhether to enable lazy mounting |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Title
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Root
| Prop | Default | Type |
|---|---|---|
aria-label | — | stringHuman readable label for the dialog, in event the dialog title is not rendered |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
closeOnEscape | true | false | trueWhether to close the dialog when the escape key is pressed |
closeOnInteractOutside | true | false | trueWhether to close the dialog when the outside is clicked |
defaultOpen | — | false | trueThe initial open state of the dialog when it is first rendered. Use when you do not need to control its open state. |
finalFocusEl | — | () => HTMLElement | nullElement to receive focus when the dialog is closed |
id | — | stringThe unique identifier of the machine. |
ids | — | Partial<{ trigger: string; positioner: string; backdrop: string; content: string; closeTrigger: string; title: string; description: string; }>The ids of the elements in the dialog. Useful for composition. |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
initialFocusEl | — | () => HTMLElement | nullElement to receive focus when the dialog is opened |
lazyMount | false | false | trueWhether to enable lazy mounting |
modal | true | false | trueWhether to prevent pointer interaction outside the element and hide all content below it |
onEscapeKeyDown | — | (event: KeyboardEvent) => voidFunction called when the escape key is pressed |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
onFocusOutside | — | (event: calendar.FocusOutsideEvent) => voidFunction called when the focus is moved outside the component |
onInteractOutside | — | (event: calendar.InteractOutsideEvent) => voidFunction called when an interaction happens outside the component |
onOpenChange | — | (details: dialog.OpenChangeDetails) => voidCallback to be invoked when the dialog is opened or closed |
onPointerDownOutside | — | (event: calendar.PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component |
open | — | false | trueWhether the dialog is open |
persistentElements | — | (() => Element | null)[]Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event |
present | — | false | trueWhether the node is present (controlled by the user) |
preventScroll | true | false | trueWhether to prevent scrolling behind the dialog when it's opened |
restoreFocus | — | false | trueWhether to restore focus to the element that had focus before the dialog was opened |
role | "dialog" | "dialog" | "alertdialog"The dialog's role |
trapFocus | true | false | trueWhether to trap focus inside the dialog when it's opened |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Backdrop
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
CloseTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Context
| Prop | Default | Type |
|---|---|---|
children* | — | (context: UseDialogContext) => ReactNode |
Description
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | UseDialogReturn |
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
lazyMount | false | false | trueWhether to enable lazy mounting |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
present | — | false | trueWhether the node is present (controlled by the user) |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Title
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | false | trueUse the provided child element as the default rendered element, combining their props and behavior. |
Root
| Prop | Default | Type |
|---|---|---|
aria-label | — | stringHuman readable label for the dialog, in event the dialog title is not rendered |
children | — | null | number | false | true | Node | solid_js118.JSX.ArrayElement | (string & {}) |
closeOnEscape | true | false | trueWhether to close the dialog when the escape key is pressed |
closeOnInteractOutside | true | false | trueWhether to close the dialog when the outside is clicked |
defaultOpen | — | false | trueThe initial open state of the dialog when it is first rendered. Use when you do not need to control its open state. |
finalFocusEl | — | () => HTMLElement | nullElement to receive focus when the dialog is closed |
id | — | stringThe unique identifier of the machine. |
ids | — | Partial<{ trigger: string; positioner: string; backdrop: string; content: string; closeTrigger: string; title: string; description: string; }>The ids of the elements in the dialog. Useful for composition. |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
initialFocusEl | — | () => HTMLElement | nullElement to receive focus when the dialog is opened |
lazyMount | false | false | trueWhether to enable lazy mounting |
modal | true | false | trueWhether to prevent pointer interaction outside the element and hide all content below it |
onEscapeKeyDown | — | (event: KeyboardEvent) => voidFunction called when the escape key is pressed |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
onFocusOutside | — | (event: dialog.FocusOutsideEvent) => voidFunction called when the focus is moved outside the component |
onInteractOutside | — | (event: dialog.InteractOutsideEvent) => voidFunction called when an interaction happens outside the component |
onOpenChange | — | (details: OpenChangeDetails) => voidCallback to be invoked when the dialog is opened or closed |
onPointerDownOutside | — | (event: dialog.PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component |
open | — | false | trueWhether the dialog is open |
persistentElements | — | (() => Element | null)[]Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event |
present | — | false | trueWhether the node is present (controlled by the user) |
preventScroll | true | false | trueWhether to prevent scrolling behind the dialog when it's opened |
restoreFocus | — | false | trueWhether to restore focus to the element that had focus before the dialog was opened |
role | "dialog" | "dialog" | "alertdialog"The dialog's role |
trapFocus | true | false | trueWhether to trap focus inside the dialog when it's opened |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Backdrop
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js118.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
CloseTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js118.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js118.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Context
| Prop | Default | Type |
|---|---|---|
children* | — | (context: UseDialogContext) => Element |
Description
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js118.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js118.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | UseDialogReturn |
children | — | null | number | false | true | Node | solid_js118.JSX.ArrayElement | (string & {}) |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
lazyMount | false | false | trueWhether to enable lazy mounting |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
present | — | false | trueWhether the node is present (controlled by the user) |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Title
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js118.JSX.HTMLAttributes<HTMLHeadingElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | (props: (userProps?: solid_js118.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.ElementUse the provided child element as the default rendered element, combining their props and behavior. |
Root
| Prop | Default | Type |
|---|---|---|
aria-label | — | stringHuman readable label for the dialog, in event the dialog title is not rendered |
children | — | Snippet<[]> | undefined |
closeOnEscape | true | false | trueWhether to close the dialog when the escape key is pressed |
closeOnInteractOutside | true | false | trueWhether to close the dialog when the outside is clicked |
defaultOpen | — | false | true |
finalFocusEl | — | () => HTMLElement | nullElement to receive focus when the dialog is closed |
id | — | string |
ids | — | Partial<{ trigger: string; positioner: string; backdrop: string; content: string; closeTrigger: string; title: string; description: string; }>The ids of the elements in the dialog. Useful for composition. |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
initialFocusEl | — | () => HTMLElement | nullElement to receive focus when the dialog is opened |
lazyMount | false | false | trueWhether to enable lazy mounting |
modal | true | false | trueWhether to prevent pointer interaction outside the element and hide all content below it |
onEscapeKeyDown | — | (event: KeyboardEvent) => voidFunction called when the escape key is pressed |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
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 |
onOpenChange | — | (details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").DialogOpenChangeDetails) => voidCallback to be invoked when the dialog is opened or closed |
onPointerDownOutside | — | ((event: PointerDownOutsideEvent) => void) | undefinedFunction called when the pointer is pressed down outside the component |
open | — | false | trueWhether the dialog is open |
persistentElements | — | (() => Element | null)[]Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event |
present | — | false | trueWhether the node is present (controlled by the user) |
preventScroll | true | false | trueWhether to prevent scrolling behind the dialog when it's opened |
restoreFocus | — | false | trueWhether to restore focus to the element that had focus before the dialog was opened |
role | "dialog" | "dialog" | "alertdialog"The dialog's role |
skipAnimationOnMount | false | false | trueWhether to allow the initial presence animation. |
trapFocus | true | false | trueWhether to trap focus inside the dialog when it's opened |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Backdrop
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
CloseTrigger
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]> |
children | — | Snippet<[]> | undefined |
Content
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
Context
| Prop | Default | Type |
|---|---|---|
children* | — | Snippet<[UseDialogContext]> |
Description
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"p">]> |
children | — | Snippet<[]> | undefined |
Positioner
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
RootProvider
| Prop | Default | Type |
|---|---|---|
value* | — | UseDialogReturn |
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]> |
children | — | Snippet<[]> | undefined |
immediate | — | false | trueWhether to synchronize the present change immediately or defer it to the next frame |
lazyMount | false | false | trueWhether to enable lazy mounting |
onExitComplete | — | () => voidFunction called when the animation ends in the closed state |
present | — | false | trueWhether the node is present (controlled by the user) |
skipAnimationOnMount | false | false | trueWhether to allow the initial presence animation. |
unmountOnExit | false | false | trueWhether to unmount on exit. |
Title
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"h2">]> |
children | — | Snippet<[]> | undefined |
Trigger
| Prop | Default | Type |
|---|---|---|
asChild | — | import("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]> |
children | — | Snippet<[]> | undefined |