ShadcnUI.Components.Overlays.Dialog (shadcn_ui v1.0.0)

Copy Markdown View Source

A native modal Dialog with declarative invocation and explicit exit.

The browser owns modality, focus containment, Escape, light dismiss, and restoration. initial_focus only places native autofocus in the rendered snapshot. Applications own state, replacement, forms, commands, outcomes, and any reinvocation after a server-rendered subtree is replaced.

Summary

Functions

Renders an initially closed native dialog and its show-modal invoker.

Functions

dialog(assigns)

Renders an initially closed native dialog and its show-modal invoker.

Supply either one title slot or a nonblank accessible_label, never both. content and close are the explicit autofocus choices; auto leaves initial focus selection entirely to the browser. A caller supporting browsers below the declarative invoker capability floor should provide fallback.

Attributes

  • id (:string) (required)
  • accessible_label (:string) - Defaults to nil.
  • dismissal (:atom) - Defaults to :close_request. Must be one of :none, :close_request, or :any.
  • initial_focus (:atom) - Defaults to :auto. Must be one of :auto, :content, or :close.
  • size (:atom) - Defaults to :default. Must be one of :small, :default, :large, or :full.
  • alignment (:atom) - Defaults to :start. Must be one of :start, or :center.
  • density (:atom) - Defaults to :comfortable. Must be one of :compact, or :comfortable.
  • class (:any) - Defaults to nil.
  • trigger_class (:any) - Defaults to nil.
  • content_class (:any) - Defaults to nil.
  • close_class (:any) - Defaults to nil.
  • trigger_rest (:map) - Defaults to %{}.
  • dialog_rest (:map) - Defaults to %{}.
  • content_rest (:map) - Defaults to %{}.
  • close_rest (:map) - Defaults to %{}.
  • Global attributes are accepted.

Slots

  • trigger (required)
  • title
  • description
  • inner_block (required)
  • close (required)
  • fallback