Skip to content

Modal

A dialog on the native <dialog> element: focus trap, Escape, inert background and focus return from the platform.

CSS + mian.js JSON Markdown Registry item

Edit profile

Edit profile

Make changes to your profile here. Click save when you're done.

Confirmation

Delete account?

This permanently deletes your account and all of its data. This cannot be undone.

Installation

Everything ships in one stylesheet and one small script. There is nothing to import per component.

<link rel="stylesheet" href="https://mian.ro/dist/mian.css">
<script src="https://mian.ro/dist/mian.js" defer></script>

Prefer to own the files? /r/modal.json is a registry item with this component's CSS and example markup, ready to copy into your project with any tool that reads the open registry-item format.

Class reference

Class / attributeDescription
dialog.mn-modalThe dialog.
mn-modal-header · mn-modal-title · mn-modal-description · mn-modal-body · mn-modal-footerParts.
mn-modal-sm · mn-modal-lg · mn-modal-fullSizes.
mn-modal-sheetBecomes a bottom sheet on phones.
data-mn-open="id" · data-mn-closeOpen and close triggers.
data-mn-staticIgnore backdrop clicks and Escape, for flows that must be completed.
mn-closeThe × button.

Accessibility

  • showModal() makes everything else inert and traps focus. mian.js sets aria-labelledby from the title.
  • For destructive confirmations add role="alertdialog" and put focus on the least destructive button with autofocus.
Choose a noodle

Minimal

Flat

Pixel

Linear

Thin

Glass

Textured

Bold

Elegant

Rounded

On this page