Moey Icons
No results. Try “dialog”, “dark” or “grid”.
Components

Dialog

Modal dialogs on the native <dialog> element — the browser handles focus trapping, the inert background, Esc and returning focus. On phones they become bottom sheets.

Invite people

They'll get an email with a link to join Moey.

Delete order #10421?

This can't be undone. The customer won't be notified.

Terms of service

1. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

2. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

3. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

4. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

5. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

6. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

7. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

8. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

9. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

10. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

11. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

12. The header and footer stay put while this body scrolls. Long content never pushes the buttons off screen, and the page behind doesn't scroll.

Edit product

Linen tote · SKU LT-001

Finish setup first

Even Esc won't close this one — only the button below does.
<button class="btn btn-default" data-moey-open="#invite">Invite people</button>

<dialog class="dialog" id="invite" aria-labelledby="invite-title">
  <div class="dialog-header">
    <div>
      <h2 class="dialog-title" id="invite-title">Invite people</h2>
      <p class="dialog-description">They'll get an email with a link.</p>
    </div>
    <button class="btn-close" aria-label="Close"></button>
  </div>
  <div class="dialog-body">…</div>
  <div class="dialog-footer">
    <button class="btn btn-gray btn-ghost" data-moey-dismiss>Cancel</button>
    <button class="btn btn-default">Send invites</button>
  </div>
</dialog>

With moey.js it all works on its own:

  • Open — any element with data-moey-open="#id".
  • Close — the .btn-close, any data-moey-dismiss button, or Esc. A <form method="dialog"> closes it too, and the clicked button's value becomes returnValue.
  • Clicking outside doesn't close it — a stray click never throws away a half-filled form; it gives a small bump instead. Opt in with data-moey-close-outside="true". Same for drawers and sheets — see the examples.
  • Static — data-moey-static: nothing but your own buttons closes it (no outside click, no Esc).
  • Focus — goes to the dialog itself, or to the element with autofocus (e.g. the first input of a form).
  • On phones — it becomes a bottom sheet with a handle you can drag down to close. Want a sheet on every screen size? Use .sheet. Rather have it cover the phone's screen? Add .dialog-fullscreen-phone.
ClassWhat it does
.dialog-sm · -lg · -xl384 · 768 · 1152px wide (default 512px) — never wider than the screen
.dialog-fitAs wide as its content
--mo-dialog-widthAny width: 600px, 40rem, 80%, fit-content, or auto (as wide as the screen allows). On the dialog or any parent.
.dialog-fullscreenCovers the whole screen (big editors, previews); content clears the notch and home bar
.dialog-dividedLines under the header and above the footer — for long, scrolling content
.dialog-body.dialog-flushEdge-to-edge body — a list-group-flush inside gets full-width rows lined up with the dialog's padding (action lists, pickers)
data-moey-close-outside="true"A click outside closes it (off by default). On <body> it sets the page default.
data-moey-staticOnly your own buttons close it
.dialog-centerStays centered on phones instead of becoming a bottom sheet
.dialog-fullscreen-phoneA normal dialog on larger screens, the whole screen on phones (under 576px) instead of a bottom sheet: a post, a long form, a reader
.dialog-icon + theme-*Round icon for confirm dialogs
--mo-dialog-padding · --mo-dialog-footer-paddingInner spacing (24px) · space above and below the footer buttons (14px)
--mo-dialog-bg · --mo-dialog-fgBackground and text of dialogs, drawers and sheets. Set them on :root to give every one your page's colors (a theme with its own palette), or on one dialog

Full screen on phones

A post, an article or a long form reads better on the whole screen of a phone than in a sheet. .dialog-fullscreen-phone keeps a normal dialog on larger screens and covers the screen under 576px (clearing the notch and home bar). Make the window narrow to see it switch:

Packing day

Posted by the studio · 4 min read

Every Friday the whole week's orders go out at once. The totes are folded in thirds, the mugs get a paper sleeve, and every box gets a handwritten note.

On a phone this dialog fills the screen like a page of its own; on a laptop it stays a dialog over the page.

<dialog class="dialog dialog-lg dialog-fullscreen-phone" id="post" aria-labelledby="post-title">…</dialog>

Your page has its own colors (a theme, a blog)? Give the dialogs the same ones, once, for the whole page:

:root {
  --mo-dialog-bg: #fbf7f0;   /* dialogs, drawers and sheets */
  --mo-dialog-fg: #2b2622;
}

Clicking outside

By default a click on the dimmed area doesn't close a dialog, drawer or sheet — it gives a small bump, so a stray click never throws away a half-filled form. Esc and your own buttons still close it. Opt in where closing is harmless:

Defaultdata-moey-close-outside="true"
Dialog
Drawer
Sheet

Click outside — it stays

Clicking the dimmed area only bumps it. Use ✕, the button or Esc.

Click outside to close

This one has data-moey-close-outside="true". Click the dimmed area.

Click outside — it stays

Clicking the dimmed area only bumps it. Use ✕, the button or Esc.

Click outside to close

This one has data-moey-close-outside="true". Click the dimmed area.

Click outside — it stays

Clicking the dimmed area only bumps it. Use ✕, the button or Esc.

Click outside to close

This one has data-moey-close-outside="true". Click the dimmed area.
<dialog class="drawer" data-moey-close-outside="true">…</dialog>   <!-- this one closes on a click outside -->

<body data-moey-close-outside="true">     <!-- every dialog, drawer and sheet on the page -->
<dialog class="dialog" data-moey-close-outside="false">   <!-- …except this one -->
How it closesDefaultdata-moey-close-outside="true"data-moey-static
✕, data-moey-dismiss, your buttons✓✓✓
Esc✓✓— (bumps)
Click outside— (bumps)✓— (bumps)
Drag down (sheets)✓✓— (springs back)

From code & events

Moey.open(document.querySelector('#invite'));
Moey.close(dialog, 'saved');

dialog.addEventListener('moey:close', (e) => {
  if (formHasUnsavedChanges) e.preventDefault();   // keep it open
});
document.addEventListener('moey:closed', (e) => console.log(e.detail.returnValue));

Events: moey:open (cancelable) · moey:opened · moey:close (cancelable) · moey:closed.

Sizes

Small · 384px

Confirmations and short messages.

Default · 512px

Most forms fit here.

Large · 768px

Tables, previews, longer forms.

As wide as its content

.dialog-fit
<dialog class="dialog dialog-sm">…</dialog>     <!-- 384px -->
<dialog class="dialog">…</dialog>               <!-- 512px -->
<dialog class="dialog dialog-lg">…</dialog>     <!-- 768px -->
<dialog class="dialog dialog-fit">…</dialog>    <!-- as wide as its content -->

Form with validation

Required fields are checked before the dialog closes — the browser does it, no code needed.

New customer

Enter a valid email address.
<dialog class="dialog" id="new-customer">
  <form class="contents" method="dialog">
    <div class="dialog-body">
      <input class="form-control" required autofocus>
      <input class="form-control" type="email" required>
      <div class="form-error">Enter a valid email address.</div>
    </div>
    <div class="dialog-footer">
      <button type="button" class="btn btn-ghost" data-moey-dismiss>Cancel</button>   <!-- not a submit button, so Enter submits the form -->
      <button class="btn btn-default" value="save">Add customer</button>
    </div>
  </form>
</dialog>

Type to confirm

For things that can2019t be undone: the delete button only works once the name is typed (pattern does the check).

Delete “Moey Supply”?

All orders and customers are removed for good.

<input class="form-control" required pattern="Moey Supply">
<button class="btn btn-red" value="delete">Delete store</button>