Dialog
A window overlaid on either the primary window or another dialog window.
import Dialog from '@corvu/dialog'
import type { VoidComponent } from 'solid-js'
const DialogExample: VoidComponent = () => {
return (
<Dialog>
<Dialog.Trigger class="my-auto rounded-lg bg-corvu-100 px-4 py-3 text-lg font-medium transition-all duration-100 hover:bg-corvu-200 active:translate-y-0.5">
Open Dialog
</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Overlay class="fixed inset-0 z-50 bg-black/50" />
<Dialog.Content class="fixed left-1/2 top-1/2 z-50 min-w-[320px] -translate-x-1/2 -translate-y-1/2 rounded-lg border-2 border-corvu-400 bg-corvu-100 px-6 py-5 duration-200 corvu-open:animate-in corvu-open:fade-in-0 corvu-open:zoom-in-95 corvu-open:slide-in-from-left-1/2 corvu-open:slide-in-from-top-[60%] corvu-closed:animate-out corvu-closed:fade-out-0 corvu-closed:zoom-out-95 corvu-closed:slide-out-to-left-1/2 corvu-closed:slide-out-to-top-[60%]">
<Dialog.Label class="text-lg font-bold">
Survey about SolidJS
</Dialog.Label>
<Dialog.Description class="mt-2">
Tell us what you like about Solid the most!
</Dialog.Description>
<textarea class="mt-3 w-full rounded border-2 border-corvu-400 bg-corvu-100 focus:outline-none" />
<div class="mt-3 flex justify-between">
<Dialog.Close class="rounded-md bg-corvu-200 px-3 py-2">
Cancel
</Dialog.Close>
<Dialog.Close class="rounded-md bg-corvu-300 px-3 py-2 font-bold">
Submit
</Dialog.Close>
</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog>
)
}
export default DialogExample
import animatePlugin from 'tailwindcss-animate'
import corvuPlugin from '@corvu/tailwind'
import formsPlugin from '@tailwindcss/forms'
/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{ts,tsx}'],
theme: {
extend: {
colors: {
corvu: {
bg: '#f3f1fe',
100: '#e6e2fd',
200: '#d4cbfb',
300: '#bcacf6',
400: '#a888f1',
text: '#180f24',
},
},
},
},
plugins: [animatePlugin, corvuPlugin, formsPlugin],
}
import './index.css'
import Dialog from '@corvu/dialog'
import type { VoidComponent } from 'solid-js'
const DialogExample: VoidComponent = () => {
return (
<Dialog>
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Overlay />
<Dialog.Content>
<Dialog.Label>Survey about SolidJS</Dialog.Label>
<Dialog.Description>
Tell us what you like about Solid the most!
</Dialog.Description>
<textarea />
<div class="button_wrapper">
<Dialog.Close class="cancel_button">Cancel</Dialog.Close>
<Dialog.Close class="submit_button">Submit</Dialog.Close>
</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog>
)
}
export default DialogExample
[data-corvu-dialog-trigger] {
margin-top: auto;
margin-bottom: auto;
border-radius: 0.5rem;
background-color: hsl(249, 87%, 94%);
padding-left: 1rem;
padding-right: 1rem;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
font-size: 1.125rem;
line-height: 1.75rem;
font-weight: 500;
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
transition-duration: 100ms;
animation-duration: 100ms;
}
[data-corvu-dialog-trigger]:hover {
background-color: hsl(251, 86%, 89%);
}
[data-corvu-dialog-trigger]:active {
transform: translate(0px, 0.125rem);
}
[data-corvu-dialog-overlay] {
position: fixed;
inset: 0px;
z-index: 50;
background-color: rgb(0 0 0 / 0.5);
}
[data-corvu-dialog-content] {
position: fixed;
left: 50%;
top: 50%;
z-index: 50;
min-width: 320px;
transform: translate(-50%, -50%);
border-radius: 0.5rem;
border-width: 2px;
border-color: hsl(258, 79%, 74%);
background-color: hsl(249, 87%, 94%);
padding-left: 1.5rem;
padding-right: 1.5rem;
padding-top: 1.25rem;
padding-bottom: 1.25rem;
animation-duration: 200ms;
}
[data-corvu-dialog-content][data-open] {
animation-name: enter;
animation-duration: 150ms;
--tw-enter-opacity: initial;
--tw-enter-scale: initial;
--tw-enter-rotate: initial;
--tw-enter-translate-x: initial;
;
--tw-enter-translate-y: initial --tw-enter-opacity: 0;
--tw-enter-scale: .95;
--tw-enter-translate-x: -50%;
--tw-enter-translate-y: -60%;
}
[data-corvu-dialog-content][data-closed] {
animation-name: exit;
animation-duration: 150ms;
--tw-exit-opacity: initial;
--tw-exit-scale: initial;
--tw-exit-rotate: initial;
--tw-exit-translate-x: initial;
--tw-exit-translate-y: initial;
--tw-exit-opacity: 0;
--tw-exit-scale: .95;
--tw-exit-translate-x: -50%;
--tw-exit-translate-y: -60%;
}
@keyframes enter {
from {
opacity: var(--tw-enter-opacity, 1);
transform: translate3d(var(--tw-enter-translate-x, 0), var(--tw-enter-translate-y, 0), 0) scale3d(var(--tw-enter-scale, 1), var(--tw-enter-scale, 1), var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))
}
}
@keyframes exit {
to {
opacity: var(--tw-exit-opacity, 1);
transform: translate3d(var(--tw-exit-translate-x, 0), var(--tw-exit-translate-y, 0), 0) scale3d(var(--tw-exit-scale, 1), var(--tw-exit-scale, 1), var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))
}
}
[data-corvu-dialog-label] {
font-size: 1.125rem;
line-height: 1.75rem;
font-weight: 700;
}
[data-corvu-dialog-description] {
margin-top: 0.5rem;
}
textarea {
margin-top: 0.75rem;
width: 100%;
border-radius: 0.25rem;
border-width: 2px;
border-color: hsl(258, 79%, 74%);
background-color: hsl(249, 87%, 94%);
}
textarea:focus {
outline: 2px solid transparent;
outline-offset: 2px;
}
.button_wrapper {
margin-top: 0.75rem;
display: flex;
justify-content: space-between;
}
[data-corvu-dialog-close] {
border-radius: 0.375rem;
padding-left: 0.75rem;
padding-right: 0.75rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
}
.cancel_button {
background-color: hsl(251, 86%, 89%);
}
.submit_button {
background-color: hsl(253, 80%, 82%);
}
Features Section titled Features
- Supports modal and non-modal modes
- Customizable focus management
- Waits for pending animations before removing the dialog from the DOM
- Pressing the escape key and interacting outside closes the dialog
- Supports nested dialogs
Installation Section titled Installation
npm install @corvu/dialog
The dialog is also included in the main corvu
package under corvu/dialog
.
Usage Section titled Usage
import Dialog from '@corvu/dialog' // 'corvu/dialog'
// or
// import { Root, Trigger, ... } from '@corvu/dialog'
Anatomy Section titled Anatomy
<Dialog>
<Dialog.Trigger />
<Dialog.Portal>
<Dialog.Overlay />
<Dialog.Content>
<Dialog.Close />
<Dialog.Label />
<Dialog.Description />
</Dialog.Content>
</Dialog.Portal>
</Dialog>
Scrolling Section titled Scrolling
By default, corvu prevents scrolling of elements outside of the dialog content while the dialog open. It will also add additional padding to the body to prevent the page from jumping when the scrollbar disappears. There is also a CSS variable called --scrollbar-width
which is present when the scrollbar is hidden. You can use this to prevent any fixed element from jumping:
<header
class="fixed top-0 inset-x-0 z-50"
style={{
'padding-right': 'var(--scrollbar-width, 0)',
}}
>
Header
</header>
Nested dialogs Section titled Nested dialogs
Feel free to nest dialogs however you want. corvu is aware of nested dialogs and only dismisses the top-most dialog when you press the escape key or click outside the dialog.
import Dialog from '@corvu/dialog'
import type { VoidComponent } from 'solid-js'
const DialogExample: VoidComponent = () => {
return (
<Dialog>
<Dialog.Trigger class="my-auto rounded-lg bg-corvu-100 px-4 py-3 text-lg font-medium transition-all duration-100 hover:bg-corvu-200 active:translate-y-0.5">
Open Dialog
</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Overlay class="fixed inset-0 z-50 bg-black/50" />
<Dialog.Content class="fixed left-1/2 top-1/2 z-50 min-w-[320px] -translate-x-1/2 -translate-y-1/2 rounded-lg border-2 border-corvu-400 bg-corvu-100 px-6 py-5 duration-200 corvu-open:animate-in corvu-open:fade-in-0 corvu-open:zoom-in-95 corvu-open:slide-in-from-left-1/2 corvu-open:slide-in-from-top-[60%] corvu-closed:animate-out corvu-closed:fade-out-0 corvu-closed:zoom-out-95 corvu-closed:slide-out-to-left-1/2 corvu-closed:slide-out-to-top-[60%]">
<Dialog.Label class="text-lg font-bold">
Nested dialog example
</Dialog.Label>
<div class="mt-3 flex justify-between">
<Dialog.Close class="rounded-md bg-corvu-200 px-3 py-2">
Close
</Dialog.Close>
<Dialog>
<Dialog.Trigger class="rounded-md bg-corvu-300 px-3 py-2 font-bold">
Open another dialog!
</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Content class="fixed left-1/2 top-1/2 z-50 flex h-[150px] w-[320px] -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center space-y-4 rounded-lg border-2 border-corvu-400 bg-corvu-100 px-6 py-5 duration-200 corvu-open:animate-in corvu-open:fade-in-0 corvu-open:zoom-in-95 corvu-open:slide-in-from-left-1/2 corvu-open:slide-in-from-top-[60%] corvu-closed:animate-out corvu-closed:fade-out-0 corvu-closed:zoom-out-95 corvu-closed:slide-out-to-left-1/2 corvu-closed:slide-out-to-top-[60%]">
<Dialog.Label class="text-lg font-bold">
Hey! I'm a nested dialog 🐦⬛
</Dialog.Label>
<Dialog.Close class="rounded-md bg-corvu-300 px-3 py-2">
Close me
</Dialog.Close>
</Dialog.Content>
</Dialog.Portal>
</Dialog>
</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog>
)
}
export default DialogExample
import animatePlugin from 'tailwindcss-animate'
import corvuPlugin from '@corvu/tailwind'
import formsPlugin from '@tailwindcss/forms'
/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{ts,tsx}'],
theme: {
extend: {
colors: {
corvu: {
bg: '#f3f1fe',
100: '#e6e2fd',
200: '#d4cbfb',
300: '#bcacf6',
400: '#a888f1',
text: '#180f24',
},
},
},
},
plugins: [animatePlugin, corvuPlugin, formsPlugin],
}
Persistent content Section titled Persistent content
To persist the content of the dialog even when it’s unmounted, you can use corvu’s createPersistent
utility. It will cache the content when the dialog is opened for the first time and preserve its state and HTML elements.
const PersistedDialogContent = () => {
const persistedContent = createPersistent(() => {
return <input />
})
return (
<Dialog>
<Dialog.Trigger>
Open
</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Content>
{persistedContent()}
</Dialog.Content>
</Dialog.Portal>
</Dialog>
)
}
Give it a try! 🐦⬛
import createPersistent from 'solid-persistent'
import Dialog from '@corvu/dialog'
import type { VoidComponent } from 'solid-js'
const PersistentDialogExample: VoidComponent = () => {
const persistedContent = createPersistent(DialogContent)
return (
<Dialog>
<Dialog.Trigger class="my-auto rounded-lg bg-corvu-100 px-4 py-3 text-lg font-medium transition-all duration-100 hover:bg-corvu-200 active:translate-y-0.5">
Open Persistent Dialog
</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Overlay class="fixed inset-0 z-50 bg-black/50" />
<Dialog.Content class="fixed left-1/2 top-1/2 z-50 max-w-[500px] -translate-x-1/2 -translate-y-1/2 rounded-lg border-2 border-corvu-400 bg-corvu-100 px-6 py-5 duration-200 corvu-open:animate-in corvu-open:fade-in-0 corvu-open:zoom-in-95 corvu-open:slide-in-from-left-1/2 corvu-open:slide-in-from-top-[60%] corvu-closed:animate-out corvu-closed:fade-out-0 corvu-closed:zoom-out-95 corvu-closed:slide-out-to-left-1/2 corvu-closed:slide-out-to-top-[60%]">
{persistedContent()}
</Dialog.Content>
</Dialog.Portal>
</Dialog>
)
}
const DialogContent = () => (
<>
<Dialog.Label class="text-lg font-bold">
Persistent dialog content
</Dialog.Label>
<Dialog.Description class="mt-2">
This dialog will preserve the state inside the content,
<br /> even after it gets unmounted from the DOM.
<br /> Enter something in the input and reopen the dialog.
</Dialog.Description>
<input class="mt-4 rounded border border-corvu-200 bg-corvu-bg px-3 py-2 ring-2 ring-corvu-400 focus-visible:border focus-visible:border-corvu-200 focus-visible:ring-2 focus-visible:ring-corvu-400" />
<p class="mt-3 text-sm">
💡 I'm an uncontrolled input, preserving my state because I never
rerender!
</p>
</>
)
export default PersistentDialogExample
import animatePlugin from 'tailwindcss-animate'
import corvuPlugin from '@corvu/tailwind'
import formsPlugin from '@tailwindcss/forms'
/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{ts,tsx}'],
theme: {
extend: {
colors: {
corvu: {
bg: '#f3f1fe',
100: '#e6e2fd',
200: '#d4cbfb',
300: '#bcacf6',
400: '#a888f1',
text: '#180f24',
},
},
},
},
plugins: [animatePlugin, corvuPlugin, formsPlugin],
}
Accessibility Section titled Accessibility
Adheres to the Dialog WAI-ARIA design pattern and Alert Dialog WAI-ARIA design pattern.
API reference Section titled API reference
Context wrapper for the dialog. Is required for every dialog you create.
Props
Property | Default | Type/Description |
---|---|---|
role | 'dialog' | 'dialog' | 'alertdialog' The role attribute of the dialog element. |
open | - | boolean Whether the dialog is open. |
onOpenChange | - | (open: boolean) => void Callback fired when the open state changes. |
initialOpen | false | boolean Whether the dialog is open initially. |
modal | true | boolean Whether the dialog should be rendered as a modal. |
closeOnEscapeKeyDown | true | boolean Whether the dialog should close when the user presses the Escape key. |
onEscapeKeyDown | - | (event: KeyboardEvent) => void Callback fired when the user presses the Escape key. Can be prevented by calling event.preventDefault . |
closeOnOutsideFocus | true if trapFocus is true , false otherwise | boolean Whether the dialog should be closed if a focus event happens outside the bounds of . |
closeOnOutsidePointer | true if modal is true , false otherwise | boolean Whether the dialog should be closed if the user interacts outside the bounds of . |
closeOnOutsidePointerStrategy | 'pointerup' | 'pointerdown' | 'pointerup' Whether closeOnOutsidePointer should be triggered on pointerdown or pointerup . |
onOutsideFocus | - | (event: CustomEvent) => void Callback fired when a focus event happens outside the bounds of . Can only happen if trapFocus is set to false and can be prevented by calling event.preventDefault . |
onOutsidePointer | - | (event: PointerEvent) => void Callback fired when the user interacts outside the bounds of . Can be prevented by calling event.preventDefault . |
noOutsidePointerEvents | true if modal is true , false otherwise | boolean Whether pointer events outside of should be disabled. |
preventScroll | true if modal is true , false otherwise | boolean Whether scroll outside of the dialog should be prevented. |
hideScrollbar | true | boolean Whether the scrollbar of the element should be hidden. Only applies if preventScroll is true . |
preventScrollbarShift | true | boolean Whether padding should be added to the element to avoid layout shift. |
preventScrollbarShiftMode | 'padding' | 'padding' | 'margin' Whether padding or margin should be used to avoid layout shift. |
restoreScrollPosition | true | boolean Whether to restore the scroll position with window.scrollTo to avoid possible layout shift after closing the dialog. |
allowPinchZoom | true | boolean Whether the dialog should allow pinch zoom while scroll is disabled. |
trapFocus | true | boolean Whether the dialog should trap focus. |
restoreFocus | true | boolean Whether the dialog should restore focus to the previous active element when it closes. |
initialFocusEl | - | HTMLElement The element to receive focus when the dialog opens. |
onInitialFocus | - | (event: Event) => void Callback fired when focus moves into the dialog. Can be prevented by calling event.preventDefault . |
finalFocusEl | - | HTMLElement The element to receive focus when the dialog closes. |
onFinalFocus | - | (event: Event) => void Callback fired when focus moves out of the dialog. Can be prevented by calling event.preventDefault . |
dialogId | createUniqueId() | string The id attribute of the dialog element. |
labelId | createUniqueId() | string The id attribute of the dialog label element. |
descriptionId | createUniqueId() | string The id attribute of the dialog description element. |
contextId | - | string The id of the dialog context. Useful if you have nested dialogs and want to create components that belong to a dialog higher up in the tree. |
Button that changes the open state of the dialog when clicked.
Props
Property | Default | Type/Description |
---|---|---|
as | button | ValidComponent Component to render the dynamic component as. |
contextId | - | string The id of the dialog context to use. |
Data attributes
Data attributes present on <Trigger />
components.
Property | Description |
---|---|
data-corvu-dialog-trigger | Present on every dialog trigger element. |
data-open | Present when the dialog is open. |
data-closed | Present when the dialog is closed. |
Portals its children at the end of the body element to ensure that the dialog always rendered on top.
Props
Property | Default | Type/Description |
---|---|---|
forceMount | false | boolean Whether the dialog portal should be forced to render. Useful when using third-party animation libraries. |
contextId | - | string The id of the dialog context to use. |
Component which can be used to create a faded background. Can be animated.
Props
Property | Default | Type/Description |
---|---|---|
as | div | ValidComponent Component to render the dynamic component as. |
forceMount | false | boolean Whether the dialog overlay should be forced to render. Useful when using third-party animation libraries. |
contextId | - | string The id of the dialog context to use. |
Data attributes
Data attributes present on <Overlay />
components.
Property | Description |
---|---|
data-corvu-dialog-overlay | Present on every dialog overlay element. |
data-open | Present when the dialog is open. |
data-closed | Present when the dialog is closed. |
Content of the dialog. Can be animated.
Props
Property | Default | Type/Description |
---|---|---|
as | div | ValidComponent Component to render the dynamic component as. |
forceMount | false | boolean Whether the dialog content should be forced to render. Useful when using third-party animation libraries. |
contextId | - | string The id of the dialog context to use. |
Data attributes
Data attributes present on <Content />
components.
Property | Description |
---|---|
data-corvu-dialog-content | Present on every dialog content element. |
data-open | Present when the dialog is open. |
data-closed | Present when the dialog is closed. |
Close button that changes the open state to false when clicked.
Props
Property | Default | Type/Description |
---|---|---|
as | button | ValidComponent Component to render the dynamic component as. |
contextId | - | string The id of the dialog context to use. |
Data attributes
Data attributes present on <Close />
components.
Property | Description |
---|---|
data-corvu-dialog-close | Present on every dialog close element. |
Label element to announce the dialog to accessibility tools.
Props
Property | Default | Type/Description |
---|---|---|
as | h2 | ValidComponent Component to render the dynamic component as. |
contextId | - | string The id of the dialog context to use. |
Data attributes
Data attributes present on <Label />
components.
Property | Description |
---|---|
data-corvu-dialog-label | Present on every dialog label element. |
Description element to announce the dialog to accessibility tools.
Props
Property | Default | Type/Description |
---|---|---|
as | p | ValidComponent Component to render the dynamic component as. |
contextId | - | string The id of the dialog context to use. |
Data attributes
Data attributes present on <Description />
components.
Property | Description |
---|---|
data-corvu-dialog-description | Present on every dialog description element. |
Context which exposes various properties to interact with the dialog. Optionally provide a contextId to access a keyed context.
Returns
Property | Type/Description |
---|---|
role | Accessor<'dialog' | 'alertdialog'> The role attribute of the dialog element. |
open | Accessor<boolean> Whether the dialog is open. |
setOpen | Setter<boolean> Change the open state of the dialog. |
modal | Accessor<boolean> Whether the dialog should be rendered as a modal. |
closeOnEscapeKeyDown | Accessor<boolean> Whether the dialog should close when the user presses the Escape key. |
closeOnOutsideFocus | Accessor<boolean> Whether the dialog should be closed if a focus event happens outside the bounds of . |
closeOnOutsidePointer | Accessor<boolean> Whether the dialog should be closed if the user interacts outside the bounds of . |
closeOnOutsidePointerStrategy | Accessor<'pointerdown' | 'pointerup'> Whether closeOnOutsidePointer should be triggered on pointerdown or pointerup . |
noOutsidePointerEvents | Accessor<boolean> Whether pointer events outside of should be disabled. |
preventScroll | Accessor<boolean> Whether scroll outside of the dialog should be prevented. |
hideScrollbar | Accessor<boolean> Whether the scrollbar of the element should be hidden. |
preventScrollbarShift | Accessor<boolean> Whether padding should be added to the element to avoid layout shift. |
preventScrollbarShiftMode | Accessor<'padding' | 'margin'> Whether padding or margin should be used to avoid layout shift. |
restoreScrollPosition | Accessor<boolean> Whether to restore the scroll position with window.scrollTo to avoid possible layout shift after closing the dialog. |
allowPinchZoom | Accessor<boolean> Whether the dialog should allow pinch zoom while scroll is disabled. |
trapFocus | Accessor<boolean> Whether the dialog should trap focus. |
restoreFocus | Accessor<boolean> Whether the dialog should restore focus to the previous active element when it closes. |
initialFocusEl | Accessor<HTMLElement | undefined> The element to receive focus when the dialog opens. |
finalFocusEl | Accessor<HTMLElement | undefined> The element to receive focus when the dialog closes. |
contentPresent | Accessor<boolean> Whether the dialog content is present. This differes from open as it tracks pending animations. |
contentRef | Accessor<HTMLElement | null> The ref of the dialog content. |
overlayPresent | Accessor<boolean> Whether the dialog overlay is present. This differes from open as it tracks pending animations. |
overlayRef | Accessor<HTMLElement | null> The ref of the dialog overlay. |
dialogId | Accessor<string> The id attribute of the dialog element. |
labelId | Accessor<string | undefined> The id attribute of the dialog label element. Is undefined if no Dialog.Label is present. |
descriptionId | Accessor<string | undefined> The id attribute of the dialog description element. Is undefined if no Dialog.Description is present. |
Props that are passed to the Root component children callback.
Props
Property | Type/Description |
---|---|
role | 'dialog' | 'alertdialog' The role attribute of the dialog element. |
open | boolean Whether the dialog is open. |
setOpen | Setter<boolean> Change the open state of the dialog. |
modal | boolean Whether the dialog should be rendered as a modal. |
closeOnEscapeKeyDown | boolean Whether the dialog should close when the user presses the Escape key. |
closeOnOutsideFocus | boolean Whether the dialog should be closed if a focus event happens outside the bounds of . |
closeOnOutsidePointer | boolean Whether the dialog should be closed if the user interacts outside the bounds of the dialog content. |
closeOnOutsidePointerStrategy | 'pointerdown' | 'pointerup' Whether closeOnOutsidePointer should be triggered on pointerdown or pointerup . |
noOutsidePointerEvents | boolean Whether pointer events outside of should be disabled. |
preventScroll | boolean Whether scroll outside of the dialog should be prevented. |
hideScrollbar | boolean Whether the scrollbar of the element should be hidden. |
preventScrollbarShift | boolean Whether padding should be added to the element to avoid layout shift. |
preventScrollbarShiftMode | 'padding' | 'margin' Whether padding or margin should be used to avoid layout shift. |
restoreScrollPosition | boolean Whether to restore the scroll position with window.scrollTo to avoid possible layout shift after closing the dialog. |
allowPinchZoom | boolean Whether the dialog should allow pinch zoom while scroll is disabled. |
trapFocus | boolean Whether the dialog should trap focus. |
restoreFocus | boolean Whether the dialog should restore focus to the previous active element when it closes. |
initialFocusEl | HTMLElement The element to receive focus when the dialog opens. |
finalFocusEl | HTMLElement The element to receive focus when the dialog closes. |
contentPresent | boolean Whether the dialog content is present. This differes from open as it tracks pending animations. |
contentRef | HTMLElement | null The ref of the dialog content. |
overlayPresent | boolean Whether the dialog overlay is present. This differes from open as it tracks pending animations. |
overlayRef | HTMLElement | null The ref of the dialog overlay. |
dialogId | string The id attribute of the dialog description element. |
labelId | string | undefined The id attribute of the dialog label element. Is undefined if no Dialog.Label is present. |
descriptionId | string | undefined The id attribute of the dialog description element. Is undefined if no Dialog.Description is present. |
Developed and designed by Jasmin