sterling-svelte  2.0.0
A modern, accessible, lightweight UI component library for Svelte.

Dialog

A modal, interactive content box that can be submitted or dismissed.

Code
<script lang="ts">
  import { Dialog } from '@geoffcox/sterling-svelte';
</script>

<Dialog bind:open bind:returnValue>
  <!-- Add content snippet or header, body, and footer snippets -->
</Dialog>

Members

Property NameTypeDefaultComment
backdropClosesboolean | null | undefinedfalseWhen true, clicking outside the dialog causes the dialog to close.
bodySnippet | undefinedundefinedThe body within the dialog content.
contentSnippet | undefinedundefinedThe entire content of the dialog. Defaults to header, body, and footer snippets.
footerSnippet | undefinedundefinedThe footer within the dialog content.
headerSnippet| undefinedundefinedThe header within the dialog content. Defaults to headerTitle and close button.
headerTitlestring | Snippet | undefinedundefinedThe title within the header.
openboolean | null | undefinedfalseWhen true, the dialog is open; otherwise the dialog is closed
returnValuestring | undefined''A value indicates OK, empty indicates cancellation.
variantstring''Additional class names to apply

Considerations

  • The dialog is always modal.
  • The cancel event is only raised when the escape key is pressed.
  • Includes HTMLDialogElement props, events, and methods.

Anatomy

dialog (<dialog>)
  form (<form>)
    content (<div>)
      content (Snippet)
        header (<div>)
          header (Snippet)
            title (<div>)
              headerTitle (string | Snippet)
            close (Button)
              close-x (<div>)
        body (<div>)
          body (Snippet)
        separator (<div>)
        footer (<div>)
          footer (Snippet)