View as Markdown

API reference: @salmonui/overlays/dialog

DialogPropsinterface

import type { DialogProps } from '@salmonui/overlays/dialog';
interface DialogProps extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'open' | 'title' | 'onCancel' | 'onClose'> {
    readonly children?: ReactNode;
    readonly trigger?: ReactNode;
    readonly open?: boolean | undefined;
    readonly defaultOpen?: boolean | undefined;
    readonly onOpenChange?: ((open: boolean, event: DialogOpenChangeEvent) => void) | undefined;
    readonly onAfterOpen?: (() => void) | undefined;
    readonly onAfterClose?: (() => void) | undefined;
    readonly modal?: boolean | undefined;
    readonly dismissible?: boolean | {
        readonly escape?: boolean | undefined;
        readonly outside?: boolean | undefined;
    } | undefined;
    readonly onOverlayPress?: ((event: PointerEvent) => void) | undefined;
    readonly closeButton?: boolean | undefined;
    readonly title?: ReactNode;
    readonly initialFocus?: RefObject<HTMLElement | null> | false | undefined;
    readonly returnFocus?: boolean | undefined;
    readonly container?: Element | null | undefined;
    readonly keepMounted?: boolean | undefined;
    readonly placement?: 'center' | 'top' | undefined;
    readonly position?: DialogPosition | undefined;
    readonly defaultPosition?: DialogPosition | undefined;
    readonly onPositionChange?: ((position: DialogPosition) => void) | undefined;
    readonly width?: number | string | undefined;
    readonly height?: number | string | undefined;
    readonly minHeight?: number | string | undefined;
    readonly fullScreen?: boolean | 'mobile' | undefined;
    readonly draggable?: boolean | undefined;
    readonly dragHandle?: string | undefined;
    readonly onMoveStart?: (() => void) | undefined;
    readonly onMove?: ((position: DialogPosition) => void) | undefined;
    readonly onMoveEnd?: ((position: DialogPosition) => void) | undefined;
    readonly resizable?: boolean | readonly DialogResizeEdge[] | undefined;
    readonly onResizeStart?: (() => void) | undefined;
    readonly onResize?: ((size: DialogSize) => void) | undefined;
    readonly onResizeEnd?: ((size: DialogSize) => void) | undefined;
    readonly localeText?: DialogLocaleText | undefined;
    readonly classNames?: Partial<Record<DialogPart, string>> | undefined;
    readonly styles?: Partial<Record<DialogPart, CSSProperties>> | undefined;
    readonly ref?: Ref<HTMLDialogElement> | undefined;
}
DialogProps members (37)
NameSignatureDescription
childrenoptionalreadonly children?: ReactNode;

Content parts: Dialog.Title, Dialog.Description, Dialog.Body, Dialog.Footer, Dialog.Close.

triggeroptionalreadonly trigger?: ReactNode;

Rendered before the dialog with the dialog's context: usually a Dialog.Trigger.

openoptionalreadonly open?: boolean | undefined;
defaultOpenoptionalreadonly defaultOpen?: boolean | undefined;
onOpenChangeoptionalreadonly onOpenChange?: ((open: boolean, event: DialogOpenChangeEvent) => void) | undefined;
onAfterOpenoptionalreadonly onAfterOpen?: (() => void) | undefined;
onAfterCloseoptionalreadonly onAfterClose?: (() => void) | undefined;
modaloptionalreadonly modal?: boolean | undefined;

showModal() (default) or show() (modeless: no backdrop, no focus containment).

dismissibleoptionalreadonly dismissible?: boolean | { readonly escape?: boolean | undefined; readonly outside?: boolean | undefined; } | undefined;

Escape and backdrop dismissal. true = both, false = none. Default { escape: true, outside: false }.

onOverlayPressoptionalreadonly onOverlayPress?: ((event: PointerEvent) => void) | undefined;

Press on the backdrop of a modal dialog.

closeButtonoptionalreadonly closeButton?: boolean | undefined;

A close button in the corner (label localeText.close). Default false.

titleoptionalreadonly title?: ReactNode;

Shorthand for a Dialog.Title at the top.

initialFocusoptionalreadonly initialFocus?: RefObject<HTMLElement | null> | false | undefined;

Element focused on open (else [data-autofocus], else the first focusable); false keeps the platform default.

returnFocusoptionalreadonly returnFocus?: boolean | undefined;

Return focus to the invoker on close. Default true.

containeroptionalreadonly container?: Element | null | undefined;

Modeless only: render the dialog inside this element (positioned in it) instead of in place. Mounted after hydration.

keepMountedoptionalreadonly keepMounted?: boolean | undefined;

Render the closed <dialog> too (content in the server HTML).

placementoptionalreadonly placement?: 'center' | 'top' | undefined;

'center' (default) or 'top'.

positionoptionalreadonly position?: DialogPosition | undefined;
defaultPositionoptionalreadonly defaultPosition?: DialogPosition | undefined;
onPositionChangeoptionalreadonly onPositionChange?: ((position: DialogPosition) => void) | undefined;
widthoptionalreadonly width?: number | string | undefined;
heightoptionalreadonly height?: number | string | undefined;
minHeightoptionalreadonly minHeight?: number | string | undefined;
fullScreenoptionalreadonly fullScreen?: boolean | 'mobile' | undefined;

Fill the viewport, or only below the mobile width (640 px).

draggableoptionalreadonly draggable?: boolean | undefined;

Drag by dragHandle (default the title); lazy chunk.

dragHandleoptionalreadonly dragHandle?: string | undefined;

CSS selector of the drag handle inside the dialog. Default .salmon-dialog-title.

onMoveStartoptionalreadonly onMoveStart?: (() => void) | undefined;
onMoveoptionalreadonly onMove?: ((position: DialogPosition) => void) | undefined;

Per animation frame during a drag; not for React state.

onMoveEndoptionalreadonly onMoveEnd?: ((position: DialogPosition) => void) | undefined;
resizableoptionalreadonly resizable?: boolean | readonly DialogResizeEdge[] | undefined;

Resize from ['bottomEnd'] (true) or the given edges; lazy chunk.

onResizeStartoptionalreadonly onResizeStart?: (() => void) | undefined;
onResizeoptionalreadonly onResize?: ((size: DialogSize) => void) | undefined;
onResizeEndoptionalreadonly onResizeEnd?: ((size: DialogSize) => void) | undefined;
localeTextoptionalreadonly localeText?: DialogLocaleText | undefined;
classNamesoptionalreadonly classNames?: Partial<Record<DialogPart, string>> | undefined;
stylesoptionalreadonly styles?: Partial<Record<DialogPart, CSSProperties>> | undefined;
refoptionalreadonly ref?: Ref<HTMLDialogElement> | undefined;

The <dialog> element.