Dialog

Alignment target:@astryxdesign/core v0.7.1 · Dialog

Dialog Props #

NameTypeDefaultDescription
isOpenboolean—Whether the dialog is open. Required.
isInlinebooleanfalseRenders content in normal flow without the modal dialog, backdrop, or focus behavior. For documentation previews only.
widthnumber | string400Preferred width. Numbers are pixels. Clamped to the viewport on narrow screens. Ignored by fullscreen.
maxHeightnumber | string'75vh'Maximum height. Numbers are pixels. Ignored by fullscreen.
positionDialogPositionCenteredStatic offsets: top, bottom, start, end. Logical start and end mirror under RTL. Ignored by fullscreen.
variant'standard' | 'fullscreen''standard'Standard dialog or a dialog that fills the viewport.
purpose'required' | 'form' | 'info''info'required disables Escape and backdrop dismissal. form allows Escape only. info allows both.
padding0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10Theme default (16px)Inner padding, mapped to the --astryx-spacing-* tokens.

Events #

  • openChange(isOpen: boolean): fires with false when the user requests dismissal through Escape or a backdrop click, depending on purpose. The parent sets isOpen to close.

Slots #

  • default: dialog content. Usually a DialogHeader followed by body content and actions.

DialogHeader Props #

NameTypeDefaultDescription
titlestring—Dialog title. Receives default focus on open and names the dialog. Required.
subtitlestring—Secondary text below the title. Not rendered when empty and no subtitle slot is set.
hasCloseButtonbooleanfalseShows a close button that emits openChange(false).
endContentEdgeCompensation'inline' | 'block' | 'all'all when a close button is shownWhich edges of the trailing slot are compensated. Omitted with a close button compensates block and inline end.
closeButtonLabelstringActive languageAccessible name of the close button. Defaults to Close in English and 关闭 in Chinese.
hasDividerbooleanfalseDraws a themed rule along the bottom edge, using --astryx-color-border.

DialogHeader Events and Slots #

  • openChange(isOpen: boolean): fires with false from the close button.
  • title: inline content in place of the title string.
  • subtitle: inline content for the subtitle.
  • startContent: content before the title, such as a back button.
  • endContent: content after the title, before the close button.

useImperativeDialog #

  • show(content, options?): opens the dialog with content. Options merge with the defaults passed to the hook.
  • hide(): closes the dialog.
  • isOpen: readonly ref of the open state.
  • Host: component to render once in the template.

Theme #

CSS
.my-dialog {
  --astryx-dialog-background: #fff;
  --astryx-dialog-foreground: #000;
}
  • --astryx-dialog-background: surface color.
  • --astryx-dialog-foreground: text color.
  • --astryx-dialog-overlay: backdrop color.
  • --astryx-dialog-shadow: surface shadow.
  • --astryx-dialog-padding: default inner padding when the padding prop is not set.
  • --astryx-dialog-title-color: header title color.