Modal
Modals use the native Popover API: no JavaScript to open, no focus-trap library, no z-index management. The browser puts them in the top layer and handles Esc.
Description
A modal is a <dialog> with the popover attribute and the .modal-window class, opened declaratively from a trigger button with popovertarget. The styled ::backdrop dims and blurs the page behind.
The Popover API gives you the top layer (no z-index wars), native focus handling and Esc support, with zero JavaScript. The open/close animations are pure CSS transitions plus @starting-style, and the mobile bottom sheet comes for free from the same rules.
Default widths per breakpoint: 80vw → 60vw → 40vw (desktop). The backdrop uses $color-backdrop and $filter-backdrop, the mobile margin $mobile-modal-margin. Buttons with .btn-contrast keep contrast against the panel automatically.
Modal window
The trigger opens the dialog declaratively with popovertarget. Because it is popover="manual", the modal only closes through its own buttons, which use popovertargetaction="hide". Use the plain popover attribute instead if you also want light dismiss and Esc closing.
<button class="btn" popovertarget="my-popover-dialog">Open modal window</button>
<dialog class="modal-window" popover="manual" id="my-popover-dialog">
<div class="flex-row align-center flex-full" style="margin-bottom: 1rem">
<h5 class="m-0">Modal window</h5>
<button class="btn-round sm btn-contrast" popovertarget="my-popover-dialog" popovertargetaction="hide" aria-label="Close modal window"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 1 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/></svg></button>
</div>
<p>
This dialog was opened with the Popover API.<br>
It is <code>popover="manual"</code>, so it only closes through its own buttons.
</p>
<button class="btn" popovertarget="my-popover-dialog" popovertargetaction="hide">Close</button>
</dialog>Modal sizes
Widths adapt per breakpoint. The default window goes from 80vw down to 40vw on desktop; .modal-sm goes from 60vw down to 30vw and .modal-lg from 90vw down to 70vw. On small screens every dialog docks to the bottom and slides up like a bottom sheet.
<div class="flex-row" style="align-items: center">
<button class="btn" popovertarget="modal-small">Small modal</button>
<button class="btn" popovertarget="modal-large">Large modal</button>
</div>
<dialog class="modal-window modal-sm" popover="manual" id="modal-small">
<div class="flex-row align-center flex-full" style="margin-bottom: 1rem">
<h5 class="m-0">Small modal</h5>
<button class="btn-round sm btn-contrast" popovertarget="modal-small" popovertargetaction="hide" aria-label="Close"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 1 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/></svg></button>
</div>
<p>Widths adapt per breakpoint: <code>.modal-sm</code> goes from 60vw down to 30vw on large screens.</p>
<button class="btn" popovertarget="modal-small" popovertargetaction="hide">Close</button>
</dialog>
<dialog class="modal-window modal-lg" popover="manual" id="modal-large">
<div class="flex-row align-center flex-full" style="margin-bottom: 1rem">
<h5 class="m-0">Large modal</h5>
<button class="btn-round sm btn-contrast" popovertarget="modal-large" popovertargetaction="hide" aria-label="Close"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 1 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/></svg></button>
</div>
<p>Widths adapt per breakpoint: <code>.modal-lg</code> goes from 90vw down to 70vw on large screens.</p>
<button class="btn" popovertarget="modal-large" popovertargetaction="hide">Close</button>
</dialog>Scrollable body
For long content, wrap the body in <div class="modal-body scrollable">: the window keeps its 90vh cap and the inner body scrolls at 80vh instead of growing forever. Ideal for terms and conditions or long texts that need an accept action.
<button class="btn" popovertarget="modal-terms">Open terms</button>
<dialog class="modal-window" popover="manual" id="modal-terms">
<div class="flex-row align-center flex-full" style="margin-bottom: 1rem">
<h5 class="m-0">Terms and conditions</h5>
<button class="btn-round sm btn-contrast" popovertarget="modal-terms" popovertargetaction="hide" aria-label="Close"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 1 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/></svg></button>
</div>
<div class="modal-body scrollable">
<p>1. Acceptance of terms. By accessing or using this service you agree to be bound by these terms and conditions. If you do not agree with any part of the terms, you must not use the service. These terms apply to all visitors, users and others who access the service in any way.</p>
<p>2. Modifications. We reserve the right to modify these terms at any time. We will notify registered users of material changes by email or through an announcement within the service. Your continued use of the service after the publication of revised terms constitutes your acceptance of the changes.</p>
<p>3. Accounts and security. When you create an account with us, you must provide accurate, complete and current information. You are responsible for safeguarding the password that you use to access the service and for any activities or actions under your password, whether or not you have authorized them.</p>
<p>4. Intellectual property. The service and its original content, features and functionality are owned by us and are protected by international copyright, trademark, patent, trade secret and other intellectual property laws. You may not copy, modify, distribute or create derivative works based on the service without our prior written consent.</p>
<p>5. Limitation of liability. In no event shall we be liable for any indirect, incidental, special, consequential or punitive damages, including loss of profits, data or goodwill, arising out of or in connection with your use of the service, even if we have been advised of the possibility of such damages.</p>
<p>6. Governing law. These terms shall be governed and construed in accordance with the laws of the country of the provider, without regard to its conflict of law provisions. Any dispute arising out of or relating to these terms shall be brought exclusively before the competent courts of that country.</p>
<p>7. Contact. If you have any questions about these terms, please contact us through the support channels listed on the website. We will do our best to respond to all reasonable inquiries within a reasonable period of time.</p>
</div>
<button class="btn" popovertarget="modal-terms" popovertargetaction="hide">Accept</button>
</dialog>