Modals
Dialogs that sit on top of the page: basic, sizes, position, confirm, form, scrollable and static backdrop. Basic, sizes and confirm use the modal component. The others are plain HTML and Tailwind. The script in modal.js handles opening, closing, focus and the Tab trap for all of them.
Basic
A modal is a dialog that sits on top of the page and blocks it until the person closes it. button-text or button-icon renders the button that opens it; button-label, button-variant, button-appearance and button-class set its name, look and classes. The id is on the root, the button is <id>-button and the dialog <id>-panel. A button of your own goes in the button slot and has aria-controls (<id>-panel), aria-expanded="false" and aria-haspopup="dialog". While the dialog is open the head script adds role="dialog" (or the role in data-dialog-role, see Confirm) and aria-modal="true", moves focus to the first focusable element, keeps Tab inside it, closes on Esc or a click on the backdrop, and returns focus to the trigger. A button with aria-controls but no aria-expanded inside the dialog is a close button. Name the dialog with aria-labelledby (the title) and aria-describedby. The close X
is last in the markup, so the first focus lands on the content or the first action; it is placed at the top right with absolute. To lock the page scroll, put has-[[aria-modal=true]]:overflow-hidden on <body> (this page does).
Update available
Version 2.4 is ready to install.
The update fixes the table sorting bug and adds a new export option. It takes about a minute and you can keep working while it installs.
<div id="modal-basic" class="inline-flex">
<button
id="modal-basic-button"
type="button"
aria-controls="modal-basic-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Open modal</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-basic-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg"
aria-labelledby="modal-basic-title"
aria-label="Update available"
aria-describedby="modal-basic-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-basic-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Update available
</h2>
<p id="modal-basic-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
Version 2.4 is ready to install.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>
The update fixes the table sorting bug and adds a new export option. It takes about a
minute and you can keep working while it installs.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<button
id="button-1729"
type="button"
aria-controls="modal-basic-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Install now</span>
</button>
</div>
<button
type="button"
aria-controls="modal-basic-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
Custom header
The header slot replaces the title and the description; the close button stays, and title becomes the aria-label of the dialog. A button without text needs button-label.
Invite Alex Morgan
Product manager
Alex will get an email with a link to join the workspace.
<div id="modal-custom-header" class="inline-flex">
<button
id="modal-custom-header-button"
type="button"
aria-controls="modal-custom-header-panel"
aria-expanded="false"
aria-haspopup="dialog"
aria-label="Invite a member"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 size-10 p-0 text-sm in-[.button-group-extra-small]:size-6 in-[.button-group-extra-small]:p-0 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:size-8 in-[.button-group-small]:p-0 in-[.button-group-small]:text-sm in-[.button-group-large]:size-12 in-[.button-group-large]:p-0 in-[.button-group-large]:text-base in-[.button-group-extra-large]:size-14 in-[.button-group-extra-large]:p-0 in-[.button-group-extra-large]:text-lg"
>
<i aria-hidden="true" class="fa-solid fa-user-plus"></i>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-custom-header-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg"
aria-labelledby="modal-custom-header-title"
aria-label="Invite a member"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<div class="flex items-center gap-3">
<span id="avatar-1702-wrapper" class="relative inline-flex shrink-0">
<span
id="avatar-1702"
class="inline-flex shrink-0 items-center justify-center size-10 rounded-full font-semibold text-sm bg-primary-100 dark:bg-primary-900/50 text-primary-800 dark:text-primary-300"
aria-hidden="true"
>AM</span
>
</span>
<div>
<p class="text-base font-semibold text-dominant-900 dark:text-white">
Invite Alex Morgan
</p>
<p class="text-sm text-dominant-600 dark:text-dominant-300">Product manager</p>
</div>
</div>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>Alex will get an email with a link to join the workspace.</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<button
id="button-1779"
type="button"
aria-controls="modal-custom-header-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 in-[.button-group-subtle]:bg-primary-100 in-[.button-group-subtle]:text-primary-800 in-[.button-group-subtle]:not-disabled:hover:bg-primary-200 in-[.button-group-subtle]:not-disabled:active:bg-primary-300 in-[.button-group-subtle]:focus-visible:ring-primary-700 in-[.button-group-subtle]:dark:bg-primary-900/50 in-[.button-group-subtle]:dark:text-primary-300 in-[.button-group-subtle]:dark:not-disabled:hover:bg-primary-900 in-[.button-group-subtle]:dark:focus-visible:ring-primary-400 in-[.button-group-subtle]:shadow-none in-[.button-group-outline]:inset-ring in-[.button-group-outline]:inset-ring-primary-300 in-[.button-group-outline]:bg-white in-[.button-group-outline]:text-primary-800 in-[.button-group-outline]:shadow-sm in-[.button-group-outline]:not-disabled:hover:bg-primary-50 in-[.button-group-outline]:not-disabled:active:bg-primary-100 in-[.button-group-outline]:focus-visible:ring-primary-700 in-[.button-group-outline]:dark:inset-ring-primary-700 in-[.button-group-outline]:dark:bg-dominant-900 in-[.button-group-outline]:dark:text-primary-200 in-[.button-group-outline]:dark:shadow-none in-[.button-group-outline]:dark:not-disabled:hover:bg-primary-900/50 in-[.button-group-outline]:dark:focus-visible:ring-primary-400 button-selected:bg-primary-600 button-selected:text-white button-selected:inset-ring-primary-600 button-selected:not-disabled:hover:bg-primary-700 button-selected:not-disabled:hover:text-white button-selected:not-disabled:active:bg-primary-800 button-selected:dark:bg-primary-600 button-selected:dark:inset-ring-primary-600 button-selected:dark:text-white button-selected:dark:not-disabled:hover:bg-primary-700 button-selected:dark:not-disabled:hover:text-white button-selected:dark:not-disabled:active:bg-primary-800 button-selected:in-[.button-group-solid]:bg-primary-800 button-selected:in-[.button-group-solid]:not-disabled:hover:bg-primary-800 button-selected:in-[.button-group-solid]:dark:bg-primary-800 button-selected:in-[.button-group-solid]:dark:not-disabled:hover:bg-primary-800 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Send invitation</span>
</button>
</div>
<button
type="button"
aria-controls="modal-custom-header-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
Sizes
Set the maximum width on the panel: max-w-sm, max-w-lg (the default), max-w-2xl and max-w-4xl. On a narrow screen every size fills the width, minus the page padding.
Small modal
Width max-w-sm.
The panel is as wide as its content up to this maximum, and full width minus the page padding on a narrow screen.
Medium modal
Width max-w-lg.
The panel is as wide as its content up to this maximum, and full width minus the page padding on a narrow screen.
Large modal
Width max-w-2xl.
The panel is as wide as its content up to this maximum, and full width minus the page padding on a narrow screen.
<div id="modal-size-small" class="inline-flex">
<button
id="modal-size-small-button"
type="button"
aria-controls="modal-size-small-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Small</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-size-small-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-sm"
aria-labelledby="modal-size-small-title"
aria-label="Small modal"
aria-describedby="modal-size-small-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-size-small-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Small modal
</h2>
<p
id="modal-size-small-desc"
class="mt-1 text-sm text-dominant-600 dark:text-dominant-300"
>
Width max-w-sm.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>
The panel is as wide as its content up to this maximum, and full width minus the page
padding on a narrow screen.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<button
id="button-1730"
type="button"
aria-controls="modal-size-small-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Got it</span>
</button>
</div>
<button
type="button"
aria-controls="modal-size-small-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
<div id="modal-size-medium" class="inline-flex">
<button
id="modal-size-medium-button"
type="button"
aria-controls="modal-size-medium-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Medium</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-size-medium-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg"
aria-labelledby="modal-size-medium-title"
aria-label="Medium modal"
aria-describedby="modal-size-medium-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-size-medium-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Medium modal
</h2>
<p
id="modal-size-medium-desc"
class="mt-1 text-sm text-dominant-600 dark:text-dominant-300"
>
Width max-w-lg.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>
The panel is as wide as its content up to this maximum, and full width minus the page
padding on a narrow screen.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<button
id="button-1873"
type="button"
aria-controls="modal-size-medium-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Got it</span>
</button>
</div>
<button
type="button"
aria-controls="modal-size-medium-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
<div id="modal-size-large" class="inline-flex">
<button
id="modal-size-large-button"
type="button"
aria-controls="modal-size-large-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Large</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-size-large-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-2xl"
aria-labelledby="modal-size-large-title"
aria-label="Large modal"
aria-describedby="modal-size-large-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-size-large-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Large modal
</h2>
<p
id="modal-size-large-desc"
class="mt-1 text-sm text-dominant-600 dark:text-dominant-300"
>
Width max-w-2xl.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>
The panel is as wide as its content up to this maximum, and full width minus the page
padding on a narrow screen.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<button
id="button-1945"
type="button"
aria-controls="modal-size-large-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Got it</span>
</button>
</div>
<button
type="button"
aria-controls="modal-size-large-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
Position
Change where the panel sits with the alignment of the wrapper (items-start, items-center, items-end) and its padding. Resize the window to see the bottom sheet and the full-screen version on a narrow screen.
Top aligned
Use it when the content changes height, so the title does not jump.
The dialog starts near the top of the screen instead of the centre. Align the wrapper with items-start and give it top padding.
Bottom sheet on mobile
A centred dialog on a wide screen.
On a narrow screen the panel sticks to the bottom edge with square bottom corners; from sm up it is centred.
Full screen on mobile
Fills the whole screen on a narrow screen.
Useful for a long form on a phone: the panel is as tall as the screen and has no rounded corners; from sm up it is a normal centred dialog.
<div id="modal-top" class="inline-flex">
<button
id="modal-top-button"
type="button"
aria-controls="modal-top-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 inset-ring inset-ring-dominant-300 dark:inset-ring-dominant-600 bg-white dark:bg-dominant-800 text-dominant-700 dark:text-dominant-200 dark:shadow-none shadow-sm not-disabled:hover:bg-dominant-100 dark:not-disabled:hover:bg-dominant-700 not-disabled:hover:text-dominant-900 dark:not-disabled:hover:text-white not-disabled:active:bg-dominant-200 dark:not-disabled:active:bg-dominant-600 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Top aligned</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-start justify-center px-4 pt-12 pb-4 sm:px-6 sm:pt-20">
<div
id="modal-top-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg"
aria-labelledby="modal-top-title"
aria-label="Top aligned"
aria-describedby="modal-top-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-top-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Top aligned
</h2>
<p id="modal-top-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
Use it when the content changes height, so the title does not jump.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>
The dialog starts near the top of the screen instead of the centre. Align the wrapper
with items-start and give it top padding.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
></div>
<button
type="button"
aria-controls="modal-top-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
<div id="modal-bottom" class="inline-flex">
<button
id="modal-bottom-button"
type="button"
aria-controls="modal-bottom-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 inset-ring inset-ring-dominant-300 dark:inset-ring-dominant-600 bg-white dark:bg-dominant-800 text-dominant-700 dark:text-dominant-200 dark:shadow-none shadow-sm not-disabled:hover:bg-dominant-100 dark:not-disabled:hover:bg-dominant-700 not-disabled:hover:text-dominant-900 dark:not-disabled:hover:text-white not-disabled:active:bg-dominant-200 dark:not-disabled:active:bg-dominant-600 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Bottom on mobile</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-end sm:items-center justify-center p-0 sm:p-6">
<div
id="modal-bottom-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg rounded-b-none sm:rounded-b-xl"
aria-labelledby="modal-bottom-title"
aria-label="Bottom sheet on mobile"
aria-describedby="modal-bottom-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-bottom-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Bottom sheet on mobile
</h2>
<p id="modal-bottom-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
A centred dialog on a wide screen.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>
On a narrow screen the panel sticks to the bottom edge with square bottom corners; from
sm up it is centred.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
></div>
<button
type="button"
aria-controls="modal-bottom-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
<div id="modal-full" class="inline-flex">
<button
id="modal-full-button"
type="button"
aria-controls="modal-full-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 inset-ring inset-ring-dominant-300 dark:inset-ring-dominant-600 bg-white dark:bg-dominant-800 text-dominant-700 dark:text-dominant-200 dark:shadow-none shadow-sm not-disabled:hover:bg-dominant-100 dark:not-disabled:hover:bg-dominant-700 not-disabled:hover:text-dominant-900 dark:not-disabled:hover:text-white not-disabled:active:bg-dominant-200 dark:not-disabled:active:bg-dominant-600 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Full screen on mobile</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-0 sm:p-6">
<div
id="modal-full-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg min-h-dvh rounded-none sm:min-h-0 sm:rounded-xl"
aria-labelledby="modal-full-title"
aria-label="Full screen on mobile"
aria-describedby="modal-full-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-full-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Full screen on mobile
</h2>
<p id="modal-full-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
Fills the whole screen on a narrow screen.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p>
Useful for a long form on a phone: the panel is as tall as the screen and has no rounded
corners; from sm up it is a normal centred dialog.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
></div>
<button
type="button"
aria-controls="modal-full-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
Confirm
A short question before something that cannot be undone. Say what will happen and name the thing (Delete “Website redesign”
, not Are you sure?
), and label the buttons with the action. Cancel comes first in the markup, so the first focus lands on the safe choice and Enter does not delete by accident. This is an alert dialog: alert adds data-dialog-role="alertdialog" to the panel and the head script gives it role="alertdialog" instead of dialog while it is open. A screen reader then reads the title and the description (aria-describedby, required here) at once, so the person hears the warning before choosing. Use it only for a question that needs an answer; a form or a detail view stays a plain dialog.
Delete this project?
This permanently deletes Website redesign and its 24 files. You cannot undo this.
<div id="modal-confirm" class="inline-flex">
<button
id="button-1561"
type="button"
aria-controls="modal-confirm-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 in-[.button-group-subtle]:bg-primary-100 in-[.button-group-subtle]:text-primary-800 in-[.button-group-subtle]:not-disabled:hover:bg-primary-200 in-[.button-group-subtle]:not-disabled:active:bg-primary-300 in-[.button-group-subtle]:focus-visible:ring-primary-700 in-[.button-group-subtle]:dark:bg-primary-900/50 in-[.button-group-subtle]:dark:text-primary-300 in-[.button-group-subtle]:dark:not-disabled:hover:bg-primary-900 in-[.button-group-subtle]:dark:focus-visible:ring-primary-400 in-[.button-group-subtle]:shadow-none in-[.button-group-outline]:inset-ring in-[.button-group-outline]:inset-ring-primary-300 in-[.button-group-outline]:bg-white in-[.button-group-outline]:text-primary-800 in-[.button-group-outline]:shadow-sm in-[.button-group-outline]:not-disabled:hover:bg-primary-50 in-[.button-group-outline]:not-disabled:active:bg-primary-100 in-[.button-group-outline]:focus-visible:ring-primary-700 in-[.button-group-outline]:dark:inset-ring-primary-700 in-[.button-group-outline]:dark:bg-dominant-900 in-[.button-group-outline]:dark:text-primary-200 in-[.button-group-outline]:dark:shadow-none in-[.button-group-outline]:dark:not-disabled:hover:bg-primary-900/50 in-[.button-group-outline]:dark:focus-visible:ring-primary-400 button-selected:bg-primary-600 button-selected:text-white button-selected:inset-ring-primary-600 button-selected:not-disabled:hover:bg-primary-700 button-selected:not-disabled:hover:text-white button-selected:not-disabled:active:bg-primary-800 button-selected:dark:bg-primary-600 button-selected:dark:inset-ring-primary-600 button-selected:dark:text-white button-selected:dark:not-disabled:hover:bg-primary-700 button-selected:dark:not-disabled:hover:text-white button-selected:dark:not-disabled:active:bg-primary-800 button-selected:in-[.button-group-solid]:bg-primary-800 button-selected:in-[.button-group-solid]:not-disabled:hover:bg-primary-800 button-selected:in-[.button-group-solid]:dark:bg-primary-800 button-selected:in-[.button-group-solid]:dark:not-disabled:hover:bg-primary-800 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<i aria-hidden="true" class="fa-solid fa-trash"></i><span>Delete project</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-confirm-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg"
data-dialog-role="alertdialog"
aria-labelledby="modal-confirm-title"
aria-label="Delete this project?"
aria-describedby="modal-confirm-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-confirm-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Delete this project?
</h2>
<p id="modal-confirm-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
This permanently deletes Website redesign and its 24 files. You cannot undo this.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden"></div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<div class="contents">
<button
id="button-1713"
type="button"
aria-controls="modal-confirm-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 inset-ring inset-ring-dominant-300 dark:inset-ring-dominant-600 bg-white dark:bg-dominant-800 text-dominant-700 dark:text-dominant-200 dark:shadow-none shadow-sm not-disabled:hover:bg-dominant-100 dark:not-disabled:hover:bg-dominant-700 not-disabled:hover:text-dominant-900 dark:not-disabled:hover:text-white not-disabled:active:bg-dominant-200 dark:not-disabled:active:bg-dominant-600 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Cancel</span>
</button>
<button
id="button-1775"
type="button"
aria-controls="modal-confirm-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-danger-600 text-white shadow-sm not-disabled:hover:bg-danger-700 not-disabled:active:bg-danger-800 focus-visible:ring-danger-700 dark:focus-visible:ring-danger-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Delete</span>
</button>
</div>
</div>
<button
type="button"
aria-controls="modal-confirm-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
Form
A form inside a modal. The first focus lands on the first field because the close button is last in the markup. The submit button is a plain type="submit" without aria-controls, so the browser validates first (leave the name empty to see it); only the Cancel button closes the dialog by itself. After a valid submit, close it from the submit handler: @submit.prevent="$el.querySelector('[aria-controls="modal-form-panel"]').click()", or after your request succeeds.
New project
Give it a name. You can change it later.
<div id="modal-form" class="inline-flex">
<button
id="modal-form-button"
type="button"
aria-controls="modal-form-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<i aria-hidden="true" class="fa-solid fa-plus"></i><span>New project</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-form-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg"
aria-labelledby="modal-form-title"
aria-label="New project"
aria-describedby="modal-form-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-form-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
New project
</h2>
<p id="modal-form-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
Give it a name. You can change it later.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<div id="modal-form-name-field" class="group/field">
<label
for="modal-form-name"
class="block mb-1.5 text-sm font-medium text-dominant-700 dark:text-dominant-200 group-has-[:is(input,select,textarea):disabled]/field:opacity-50 group-has-[:is(input,select,textarea):required]/field:after:content-['*'] after:ml-0.5 after:text-danger-700 dark:after:text-danger-300"
>Project name</label
>
<input
id="modal-form-name"
type="text"
class="block w-full rounded-lg bg-white dark:bg-dominant-950 text-dominant-900 dark:text-white inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 placeholder:text-dominant-600 dark:placeholder:text-dominant-400 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm read-only:bg-dominant-100 dark:read-only:bg-dominant-800"
name="name"
required
autocomplete="off"
placeholder="Website redesign"
/>
</div>
<div id="modal-form-note-field" class="group/field">
<label
for="modal-form-note"
class="block mb-1.5 text-sm font-medium text-dominant-700 dark:text-dominant-200 group-has-[:is(input,select,textarea):disabled]/field:opacity-50 group-has-[:is(input,select,textarea):required]/field:after:content-['*'] after:ml-0.5 after:text-danger-700 dark:after:text-danger-300"
>Note</label
>
<textarea
id="modal-form-note"
rows="3"
class="block w-full rounded-lg bg-white dark:bg-dominant-950 text-dominant-900 dark:text-white inset-ring inset-ring-dominant-500 dark:inset-ring-dominant-400 placeholder:text-dominant-600 dark:placeholder:text-dominant-400 read-only:bg-dominant-100 dark:read-only:bg-dominant-800 focus:inset-ring-primary-500 dark:focus:inset-ring-primary-400 focus:ring-2 focus:ring-primary-500/30 dark:focus:ring-primary-400/30 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:inset-ring-danger-600 dark:aria-invalid:inset-ring-danger-400 aria-invalid:focus:inset-ring-danger-600 dark:aria-invalid:focus:inset-ring-danger-400 aria-invalid:focus:ring-danger-600/30 dark:aria-invalid:focus:ring-danger-400/30 px-3.5 py-2.5 text-sm resize-none"
name="note"
placeholder="Optional"
></textarea>
</div>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<button
id="button-1834"
type="submit"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Create project</span>
</button>
</div>
<button
type="button"
aria-controls="modal-form-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
Scrollable
When the content is longer than the screen, limit the panel height (max-h-[calc(100dvh-2rem)]), make it a column (flex flex-col) and let only the body scroll (min-h-0 flex-1 overflow-y-auto), so the title and the buttons stay in view. The scrolling body is focusable (tabindex="0", role="region" with a name) so the keyboard can scroll it. If the body is short, the dialog is as tall as its content.
Terms of service
Last updated October 2026.
By using the service you agree to these terms. We may update them from time to time, and we will tell you before a change takes effect.
You are responsible for the content you upload and for keeping your account details safe. Do not share your password and tell us at once if you think someone else has used it.
We back up your data every night and keep the backups for thirty days. You can export everything from the settings page at any time.
The service is provided as it is. We work hard to keep it running, but we cannot promise it will never be interrupted.
If you close your account we delete your data within thirty days, except what the law requires us to keep.
These terms are governed by the law of the country where the company is registered, and any dispute goes to its courts.
Questions about these terms? Write to support and a person will answer within two working days.
<div id="modal-scroll" class="inline-flex">
<button
id="modal-scroll-button"
type="button"
aria-controls="modal-scroll-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 inset-ring inset-ring-dominant-300 dark:inset-ring-dominant-600 bg-white dark:bg-dominant-800 text-dominant-700 dark:text-dominant-200 dark:shadow-none shadow-sm not-disabled:hover:bg-dominant-100 dark:not-disabled:hover:bg-dominant-700 not-disabled:hover:text-dominant-900 dark:not-disabled:hover:text-white not-disabled:active:bg-dominant-200 dark:not-disabled:active:bg-dominant-600 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Terms of service</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-scroll-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg flex max-h-[calc(100dvh-2rem)] flex-col"
aria-labelledby="modal-scroll-title"
aria-label="Terms of service"
aria-describedby="modal-scroll-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-scroll-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Terms of service
</h2>
<p id="modal-scroll-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
Last updated October 2026.
</p>
</div>
<div
tabindex="0"
role="region"
aria-label="Terms of service content"
class="min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden"
>
<div class="space-y-3">
<p class="text-sm text-dominant-700 dark:text-dominant-200">
By using the service you agree to these terms. We may update them from time to time,
and we will tell you before a change takes effect.
</p>
<p class="text-sm text-dominant-700 dark:text-dominant-200">
You are responsible for the content you upload and for keeping your account details
safe. Do not share your password and tell us at once if you think someone else has
used it.
</p>
<p class="text-sm text-dominant-700 dark:text-dominant-200">
We back up your data every night and keep the backups for thirty days. You can export
everything from the settings page at any time.
</p>
<p class="text-sm text-dominant-700 dark:text-dominant-200">
The service is provided as it is. We work hard to keep it running, but we cannot
promise it will never be interrupted.
</p>
<p class="text-sm text-dominant-700 dark:text-dominant-200">
If you close your account we delete your data within thirty days, except what the law
requires us to keep.
</p>
<p class="text-sm text-dominant-700 dark:text-dominant-200">
These terms are governed by the law of the country where the company is registered,
and any dispute goes to its courts.
</p>
<p class="text-sm text-dominant-700 dark:text-dominant-200">
Questions about these terms? Write to support and a person will answer within two
working days.
</p>
</div>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<div class="contents">
<button
id="button-1771"
type="button"
aria-controls="modal-scroll-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-dominant-700 dark:bg-dominant-600 text-white shadow-sm not-disabled:hover:bg-dominant-800 dark:not-disabled:hover:bg-dominant-500 not-disabled:active:bg-dominant-900 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Decline</span>
</button>
<button
id="button-1810"
type="button"
aria-controls="modal-scroll-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-primary-600 text-white shadow-sm not-disabled:hover:bg-primary-700 not-disabled:active:bg-primary-800 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Accept</span>
</button>
</div>
</div>
<button
type="button"
aria-controls="modal-scroll-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>
Static backdrop
static adds data-static to the panel, so a click outside does not close the dialog. Esc still closes it, because a dialog must always have a keyboard way out.
Discard your changes?
You have unsaved changes in this form.
Clicking outside does not close this dialog, so a stray click cannot throw work away. Choose one of the buttons. Esc still closes it.
<div id="modal-static" class="inline-flex">
<button
id="modal-static-button"
type="button"
aria-controls="modal-static-panel"
aria-expanded="false"
aria-haspopup="dialog"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 inset-ring inset-ring-dominant-300 dark:inset-ring-dominant-600 bg-white dark:bg-dominant-800 text-dominant-700 dark:text-dominant-200 dark:shadow-none shadow-sm not-disabled:hover:bg-dominant-100 dark:not-disabled:hover:bg-dominant-700 not-disabled:hover:text-dominant-900 dark:not-disabled:hover:text-white not-disabled:active:bg-dominant-200 dark:not-disabled:active:bg-dominant-600 focus-visible:ring-primary-700 dark:focus-visible:ring-primary-400 gap-2 px-4 py-2.5 text-sm in-[.button-group-extra-small]:gap-1.5 in-[.button-group-extra-small]:px-2.5 in-[.button-group-extra-small]:py-1 in-[.button-group-extra-small]:text-xs in-[.button-group-small]:gap-1.5 in-[.button-group-small]:px-3 in-[.button-group-small]:py-1.5 in-[.button-group-small]:text-sm in-[.button-group-large]:gap-2 in-[.button-group-large]:px-5 in-[.button-group-large]:py-3 in-[.button-group-large]:text-base in-[.button-group-extra-large]:gap-2.5 in-[.button-group-extra-large]:px-6 in-[.button-group-extra-large]:py-3.5 in-[.button-group-extra-large]:text-lg"
>
<span>Static backdrop</span>
</button>
<div
class="fixed inset-0 z-50 overflow-y-auto bg-dominant-950/60 opacity-0 invisible transition-all duration-200 overscroll-contain motion-reduce:transition-none has-[>div>[aria-modal=true]]:visible has-[>div>[aria-modal=true]]:opacity-100"
>
<div class="flex min-h-full items-center justify-center p-4 sm:p-6">
<div
id="modal-static-panel"
class="relative w-full bg-white rounded-xl shadow-xl dark:bg-dominant-900 dark:ring-1 dark:ring-dominant-700 max-w-lg"
data-static
data-dialog-role="alertdialog"
aria-labelledby="modal-static-title"
aria-label="Discard your changes?"
aria-describedby="modal-static-desc"
>
<div class="shrink-0 p-4 pr-14 border-b border-dominant-200 dark:border-dominant-700">
<h2
id="modal-static-title"
class="text-base font-semibold text-dominant-900 dark:text-white"
>
Discard your changes?
</h2>
<p id="modal-static-desc" class="mt-1 text-sm text-dominant-600 dark:text-dominant-300">
You have unsaved changes in this form.
</p>
</div>
<div class="p-4 text-sm text-dominant-700 dark:text-dominant-200 empty:hidden">
<p class="text-sm text-dominant-700 dark:text-dominant-200">
Clicking outside does not close this dialog, so a stray click cannot throw work away.
Choose one of the buttons. <kbd>Esc</kbd> still closes it.
</p>
</div>
<div
class="flex flex-col-reverse gap-2 shrink-0 p-4 border-t border-dominant-200 dark:border-dominant-700 sm:flex-row sm:justify-end empty:hidden"
>
<button
id="button-1740"
type="button"
aria-controls="modal-static-panel"
class="cursor-pointer transition-colors inline-flex items-center justify-center rounded-lg font-semibold group peer focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:focus-visible:ring-offset-dominant-950 bg-danger-600 text-white shadow-sm not-disabled:hover:bg-danger-700 not-disabled:active:bg-danger-800 focus-visible:ring-danger-700 dark:focus-visible:ring-danger-400 gap-2 px-4 py-2.5 text-sm"
>
<span>Discard</span>
</button>
</div>
<button
type="button"
aria-controls="modal-static-panel"
aria-label="Close"
class="absolute top-3 right-3 flex items-center justify-center size-8 text-dominant-600 dark:text-dominant-300 rounded-lg cursor-pointer transition-colors hover:bg-dominant-100 dark:hover:bg-dominant-800 hover:text-dominant-900 dark:hover:text-white focus-visible:ring-2 focus-visible:ring-primary-500 dark:focus-visible:ring-primary-400 focus-visible:outline-none"
>
<i aria-hidden="true" class="fa-solid fa-xmark"> </i>
</button>
</div>
</div>
</div>
</div>