36 CSS Modals

36 copy-paste CSS modal templates for SaaS auth, Stripe payment, HIPAA consent, GDPR cookies, subscription paywalls, cart drawers, and Cmd+K command palettes — 18 new native <dialog> demos with automatic focus trap + Escape close + inert background + ::backdrop blur + @starting-style enter/exit animation, plus 18 original custom-CSS overlays with the WCAG 2.1 dialog pattern hand-wired. Compliance callouts embedded per demo: PCI DSS SAQ-A, HIPAA 45 CFR § 164, GDPR Article 7, NIST SP 800-63B, PSD2 SCA, CCPA, FTC 16 CFR § 425 (paywall auto-renewal). Scoped under .cm-NN (new native <dialog>) and .md-NN (original CSS+JS) for no-collision pasting, prefers-reduced-motion guarded, framework-agnostic.

3 pure CSS33 light JSPublished 18 new designs · Updated on

Related28 CSS Close Buttons30 CSS Login Forms20 CSS Popovers

Clean Login / Signup Overlay — preview
01 / 36Native <dialog>NEW

Clean Login / Signup Overlay

A polished dual-tab authentication overlay: one native &lt;dialog&gt; flips between Sign in and Create account with pure-CSS tabs, floating-label inputs and a blurred backdrop. The most-searched auth modal, built the accessible way.

Published

Forgot Password / Reset Link — preview
02 / 36Native <dialog>NEW

Forgot Password / Reset Link

A minimal single-input recovery dialog that swaps in place to a 'check your inbox' success state after submit — the focused account-recovery flow, with a security-conscious neutral confirmation message.

Published

Age Verification Gate — preview
03 / 36Pure CSSNEW

Age Verification Gate

A full-screen entry gate that blurs and blocks the site until the visitor confirms they're of legal age — the zero-JS compliance overlay for alcohol, gaming and regulated e-commerce, driven entirely by :has() and one checkbox.

Published

Paywall / Content Lock Blur — preview
04 / 36Native <dialog>NEW

Paywall / Content Lock Blur

A subscribe wall that blurs the article behind a strong ::backdrop filter and fades the copy into a lock, prompting the reader to subscribe or log in — the metered-content gate news and SaaS docs sites reach for.

Published

Quick View Product Details — preview
05 / 36Native <dialog>NEW

Quick View Product Details

A two-column product quick-view that pops from a grid — gallery, price, star rating, colour/size variant chips, a quantity stepper and Add to Bag — so shoppers evaluate an item without a page reload. Collapses to one column on mobile.

Published

Shopping Cart Summary Drawer — preview
06 / 36Native <dialog>NEW

Shopping Cart Summary Drawer

A right-side mini-cart that slides in over the page: line items with thumbnails and quantity, a free-shipping progress bar, live subtotal and a direct checkout CTA — the off-canvas drawer pattern, done as an accessible dialog.

Published

Promo / Newsletter Popup — preview
07 / 36Tailwind CSSNEW

Promo / Newsletter Popup

A high-contrast, timed coupon capture styled entirely with Tailwind utility classes: a bold cream card with one email field and a strong CTA that fires once after a delay. The copy-paste conversion popup for utility-first stacks.

Published

Tiered Size Chart Guide — preview
08 / 36Pure CSSNEW

Tiered Size Chart Guide

A grid-based sizing table that opens from a 'Size guide' link beside the variant picker, with a zero-JS cm/inch unit toggle — the apparel-store measurement overlay, built entirely from a checkbox and sibling selectors.

Published

Lightbox Image Gallery — preview
09 / 36Pure CSSNEW

Lightbox Image Gallery

A pure-CSS image viewer that scales a thumbnail to full-screen with prev / next navigation and a dimmed backdrop — the zero-JavaScript lightbox, driven entirely by the :target selector and anchor links.

Published

Embedded Video / Trailer Player — preview
10 / 36Native <dialog>NEW

Embedded Video / Trailer Player

A responsive modal that holds an aspect-ratio-locked player for a YouTube / Vimeo / HTML5 trailer, and blanks the source on close so audio stops instantly — the click-to-play video overlay done without layout shift.

Published

Irreversible Deletion Confirmation — preview
11 / 36Native <dialog>NEW

Irreversible Deletion Confirmation

A stark danger dialog that guards a destructive action: a warning icon, red accents and a type-to-confirm field that keeps the Delete button disabled until the user types the exact keyword. The friction that prevents accidental account deletion.

Published

Success / Error Feedback State — preview
12 / 36Tailwind CSSNEW

Success / Error Feedback State

A micro-interaction result modal that draws an animated tick for success or a shaking cross for error after an async action — styled with Tailwind utilities, the animation stroke drawn in a few keyframes. The satisfying 'it worked' / 'it failed' confirmation.

Published

Cookie Consent / GDPR Banner — preview
13 / 36CSS + JSNEW

Cookie Consent / GDPR Banner

A corner cookie sheet with Accept all, Reject all and an expandable Preferences panel of per-category toggles — semantic, keyboard-friendly and persistence-ready. The GDPR/CCPA consent pattern that respects an explicit reject.

Published

Multi-Step Onboarding Walkthrough — preview
14 / 36Native <dialog>NEW

Multi-Step Onboarding Walkthrough

A modal wizard that introduces a dashboard across three steps with Back / Next pagination, a progress indicator and a Skip escape hatch — the first-run product tour that lifts activation without a separate page.

Published

Advanced Filter & Sorting Panel — preview
15 / 36Native <dialog>NEW

Advanced Filter & Sorting Panel

A data-dense filter and sort panel that docks to the side on desktop and becomes a bottom sheet on mobile — sort radios, category checkboxes, a price range and colour swatches, with a live result count, Apply and Clear.

Published

Detailed Contact / Query Form — preview
16 / 36Native <dialog>NEW

Detailed Contact / Query Form

A multi-field support form that opens over the current dashboard view so users file a query without losing context — name, email, topic, priority and message, with inline validation and a success state. Keeps people in flow.

Published

Settings / Profile Preferences Panel — preview
17 / 36Native <dialog>NEW

Settings / Profile Preferences Panel

A tabbed preferences modal with a vertical nav separating Account, Appearance and Notifications — theme radios, custom toggle switches and clean form rows. The settings surface, with pure-CSS tab switching and native focus management.

Published

Search Command Palette (Cmd + K) — preview
18 / 36Native <dialog>NEW

Search Command Palette (Cmd + K)

A top-drop command palette opened with ⌘K / Ctrl+K: fuzzy-filter a list of actions, navigate with arrow keys, run with Enter — the developer-tool-style launcher power users now expect in every dashboard.

PublishedUpdated

Confirm Delete Modal — preview
19 / 36CSS + JS

Confirm Delete Modal

A destructive-action confirmation modal with a signature Corner Slide-and-Spin entrance — the card slides in from the bottom-right at a 3° angle then settles horizontally, giving the destructive prompt a distinct arrival that reads as intentional design rather than the standard fade-scale every SaaS uses. Sober gray + red destructive theme, item name emphasized, focus starts on Cancel (SAFE default).

PublishedUpdated

CSS Login Signin Modal — preview
20 / 36CSS + JS

CSS Login Signin Modal

A SaaS login modal with a signature Blur-In Content Drop entrance — the modal shell appears sharp instantly, then each element (brand mark → title → social buttons → divider → email/password fields → submit) drops in sequentially with staggered blur-clear (8px → 0 blur + translateY 12px → 0). Reads like a photograph developing, distinct from the standard fade-scale used by every SaaS. Muted intensity (8px blur not 20px) because auth needs trust, not spectacle.

PublishedUpdated

CSS Signup Registration Modal — preview
21 / 36CSS + JS

CSS Signup Registration Modal

A B2C signup modal with a signature Origami Fan Deploy entrance — the modal's three horizontal panels (header / form / benefits strip) fan open sequentially like Japanese origami unfolding, each panel starting rotated backward on the X-axis (rotateX(-90deg) with transform-origin: top) then settling flat. Green + warm cream palette matches the emotional shift from "come back" (login) to "welcome, new here" (signup). Medium intensity — playful enough to feel welcoming, controlled enough to feel professional.

PublishedUpdated

Stripe Payment Checkout Modal — preview
22 / 36CSS + JS

Stripe Payment Checkout Modal

A Stripe Elements-style payment checkout modal with a signature 3D Paper Fold entrance — the modal opens like an envelope unfolding via rotateX(-70deg → 0) with perspective on the parent, giving the payment surface a distinct arrival that reads as "opening a physical checkout" rather than a generic overlay. Muted intensity (70° start instead of 90°, no overshoot) because payment forms require trust — the fold is present but subtle enough to not undermine the transactional gravity.

PublishedUpdated

HIPAA Patient Consent Modal — preview
23 / 36CSS + JS

HIPAA Patient Consent Modal

A HIPAA-compliant patient consent modal for healthcare apps requiring authorization for PHI (Protected Health Information) sharing — telehealth video calls, prescription requests, patient portal access. Uses a deliberate NO-signature entrance (subtle 200ms opacity fade only, zero decorative transform) because healthcare consent contexts REQUIRE the UI to read as sober, institutional, and trustworthy. Bottom-sheet mobile pattern with medical blue palette matching MyChart, Zocdoc, Teladoc conventions.

PublishedUpdated

Age Verification Modal — preview
24 / 36CSS + JS

Age Verification Modal

An age verification gate modal for regulated products (alcohol, cannabis, adult content, tobacco, gambling) with a signature Clip-Path Circuit Iris Aperture entrance — the modal reveals through an expanding circular clip-path that opens like a camera iris, distinctive and thematic for a "gatekeeping" moment. Warm amber palette (bourbon/whiskey aesthetic — commercial default for age gates), Date of Birth trio inputs (MM / DD / YYYY), plus session/persistent checkbox.

PublishedUpdated

GDPR Cookie Preferences Modal — preview
25 / 36CSS + JS

GDPR Cookie Preferences Modal

A GDPR-compliant cookie preferences center with a signature 3D Origami Unfold entrance — the modal opens with the header + action buttons visible, then each of the 4 category rows unfolds downward one-by-one via 3D rotate3d flips like origami paper unfolding. The animation communicates the modal's core purpose (revealing your consent categories layer by layer) rather than being decorative theater. Neutral gray palette — legal compliance surfaces should be sober, not persuasive. Accept All / Reject All / Save Preferences with EQUAL visual weight (CNIL fined dark-pattern-favoring-Accept in 2022).

PublishedUpdated

Video Lightbox Modal — preview
26 / 36CSS + JS

Video Lightbox Modal

A YouTube/Vimeo video lightbox modal with a signature Glitch/Corrupt Materialize entrance — the modal appears through a chromatic RGB-split glitch flicker (matches the Terminal 404 aesthetic from the Slide-In collection Demo #18). Full-screen dark backdrop, centered video container with 16:9 aspect ratio, play button overlay. Distinctive dev-culture entrance for media contexts where technical aesthetic works (streaming platforms, dev tool demos, portfolio reels).

PublishedUpdated

Image Gallery Lightbox Modal — preview
27 / 36CSS + JS

Image Gallery Lightbox Modal

A portfolio/photography image lightbox modal with a signature Clip-Path Diamond Reveal entrance — the modal reveals through a diamond-shaped clip-path expanding from center, creating a distinctive geometric aperture unlike any standard fade or slide. Full-screen dark backdrop, centered image with caption + navigation arrows + image counter. Full intensity — image galleries are visual-first contexts where decorative entrance is expected and welcomed.

PublishedUpdated

Add to Cart Confirmation Modal — preview
28 / 36CSS + JS

Add to Cart Confirmation Modal

An e-commerce "added to cart" confirmation modal with a signature Liquid Morph / Metaball entrance — the modal materializes through an SVG filter-based liquid blob effect (gooey/metaball merge). Product image + name + price on the left, cart summary + View Cart / Continue Shopping actions on the right. Clean e-commerce palette (white card + coral CTA + neutral gray body). Full intensity — e-commerce success moments reward delight.

PublishedUpdated

Quick View Product Modal — preview
29 / 36CSS + JS

Quick View Product Modal

An e-commerce Quick View product modal with a signature Morphing Button Elastic entrance — the trigger button visually "stretches and expands" into the modal card via an elastic scale + border-radius animation, creating a satisfying spatial connection between click point and modal (unlike modals that just fade in from nowhere). Product image + variant selector + Add to Cart in a compact card. Full intensity — product discovery moments warrant delight.

PublishedUpdated

Newsletter Signup Modal — preview
30 / 36CSS + JS

Newsletter Signup Modal

A newsletter signup modal with a signature Depth-Layer Parallax entrance — three visual layers (backdrop, decorative shape, modal card) slide in from different angles at different speeds, creating a cinematic depth effect. Editorial magazine palette (cream + charcoal + accent red), single-field email input + subscribe CTA + "1-click unsubscribe" trust line. Full intensity — newsletter contexts are low-stakes marketing where visual flair converts.

PublishedUpdated

Exit-Intent Discount Modal — preview
31 / 36CSS + JS

Exit-Intent Discount Modal

An exit-intent discount modal ("Wait! 15% off before you go") with a signature Liquid Morph entrance — the modal materializes through an SVG metaball filter with dramatic scale + rotate, signaling urgency and last-chance opportunity. High-contrast e-commerce palette (bold gradient CTA + urgent countdown timer + coupon code reveal). Full intensity — exit-intent contexts warrant maximum visual grab.

PublishedUpdated

Restaurant Reservation Modal — preview
32 / 36CSS + JS

Restaurant Reservation Modal

A restaurant reservation booking modal (OpenTable/Resy-inspired) with a signature Origami Fan Deploy entrance — three horizontal panels (date, time, party size) cascade in from top like origami fans unfolding. Warm hospitality palette (cream + burgundy + gold accents), date picker + time slot grid + party size selector + Reserve CTA. Medium intensity — hospitality contexts warrant warmth and theater without frivolity.

PublishedUpdated

Order Success Confirmation Modal — preview
33 / 36CSS + JS

Order Success Confirmation Modal

An e-commerce order success confirmation modal ("Thanks for your order") with a signature Morphing Button Elastic entrance + CSS-only confetti burst — the modal expands elastically from small to full size while colorful confetti particles fire outward from center. Order summary + shipping ETA + tracking CTA + "Share your purchase" social row. Full intensity — order success is the peak dopamine moment, users EXPECT celebration UI.

PublishedUpdated

Onboarding Welcome Modal — preview
34 / 36CSS + JS

Onboarding Welcome Modal

A SaaS onboarding welcome modal ("Welcome to Northlight, Alex") with a signature Blur-In Content Drop entrance — content elements cascade in from blurred+shifted state to settled state via staggered animation-delay. Progress stepper (3 steps) + hero illustration + primary CTA + skip link. Full intensity — first-time onboarding is the peak-impression moment for SaaS product perception (Linear, Notion, Figma all use decorative onboarding).

PublishedUpdated

Terms of Service Acceptance Modal — preview
35 / 36CSS + JS

Terms of Service Acceptance Modal

A Terms of Service + Privacy Policy acceptance modal for post-signup legal consent with a sober Letter-Slide entrance — modal slides down 20px with opacity fade over 320ms ease-out, no bounce, no scale. Reads as "a document being placed on the desk" rather than the pure fade Demo #05 HIPAA uses. Distinct but still institutional. Scrollable TOS body with version tag, explicit unchecked "I have read and agree" checkbox, separate marketing consent checkbox (never bundled), Accept + Decline actions with equal visual weight.

PublishedUpdated

Password Reset Modal — preview
36 / 36CSS + JS

Password Reset Modal

A password reset request modal with a signature Corner Slide-and-Spin entrance — the modal slides in from bottom-right with subtle rotate + scale, feeling like a helpful assistant materialized rather than a distant modal. Email input for reset link + "Send reset link" CTA + "Return to sign in" link + help microcopy for account recovery. Medium intensity — auth flows are personal but not compliance-heavy.

PublishedUpdated

FAQ

Frequently asked questions

What is a CSS modal and what's the simplest recipe with proper accessibility?
A CSS modal is a floating dialog card layered above the page with a semi-transparent backdrop that dims and blocks interaction with the underlying content. The 2026 canonical recipe combines HTML semantics + CSS positioning + JavaScript focus management. HTML structure: <div class='backdrop' role='dialog' aria-modal='true' aria-labelledby='modal-title'> wrapping <div class='modal'>. CSS: backdrop is position: absolute; inset: 0 with background: rgba(0,0,0,.6) + backdrop-filter: blur(4px) + opacity: 0; visibility: hidden in closed state, animated to opacity: 1; visibility: visible when a .is-open class is toggled. The inner modal is display: flex; align-items: center; justify-content: center centered, with max-width constraint. Modal transitions in with opacity + transform: translateY(20px) scale(.98) → translateY(0) scale(1) for a subtle physical arrival. JavaScript (~25 lines): on open, save current focus (lastFocus = document.activeElement), add .is-open class, set document.documentElement.style.overflow = 'hidden' to lock body scroll, focus the first interactive element inside the modal. On close (via Escape key, backdrop click, or close button), remove class, restore scroll, restore focus to lastFocus. Critical accessibility requirements (WCAG 2.1): role='dialog' tells screen readers this is a dialog, aria-modal='true' tells them the rest of the page is inert, aria-labelledby points to the modal's heading so screen readers announce it, Escape key closes (SC 2.1.1), backdrop click closes with target check (event.target === backdrop) so clicks INSIDE the modal don't close it. Every demo in this collection ships this exact pattern.
Which modal pattern should I pick for my use case?
Decision matrix by intent. Destructive actions (delete, archive, permanently remove): Demo #01 Confirm Delete Modal — compact centered card with red destructive theme, focus starts on Cancel (SAFE default). Authentication: Demo #02 Login Modal for returning users (social auth + email/password + Forgot Password link), Demo #03 Signup Modal for new users (name + email + password + password strength meter + TOS/newsletter checkboxes), Demo #18 Password Reset for recovery flows. Payments and billing: Demo #04 Stripe Payment Checkout Modal — canonical Stripe Elements-style layout with card number + expiry + CVC + name + ZIP + order summary. PCI DSS compliance requires tokenization via Stripe.js. Healthcare and regulated industries: Demo #05 HIPAA Patient Consent Modal — bottom sheet slide-up with medical blue palette, real HIPAA-compliant consent copy. Legal and compliance: Demo #06 Age Verification (alcohol / cannabis / adult content), Demo #07 GDPR Cookie Preferences (Accept All / Reject All / Customize with per-category toggles), Demo #17 Terms of Service Agreement. E-commerce: Demo #10 Shopping Cart Slide-Over (cart with line items + subtotal + Checkout CTA), Demo #11 Product Quick View (product image + details without leaving listing page), Demo #13 Exit-Intent Discount Modal (last-chance coupon on mouse-leave), Demo #15 Order Success Confirmation. Media and content: Demo #08 Video Lightbox (embedded YouTube/Vimeo player), Demo #09 Image Gallery Lightbox (portfolio / photography). Marketing: Demo #12 Newsletter Signup Popup (corner-anchored subtle popup). Hospitality and services: Demo #14 Restaurant Reservation Modal (date + party size + time slots). SaaS onboarding: Demo #16 Full-Screen Onboarding Modal (multi-step welcome flow). All 18 demos use scoped .md-NN class names so multiple can coexist on the same page without conflicts.
How do I properly implement focus trap and keyboard navigation in a modal?
Focus trap is a WCAG 2.1 SC 2.1.2 requirement (No Keyboard Trap — inversely, keyboard users must be able to navigate WITHIN the modal without escaping to underlying page). The 4-part recipe: (1) On modal open, save the currently-focused element (lastFocus = document.activeElement). This is the element you'll return focus TO when the modal closes. (2) Move focus INTO the modal to the FIRST interactive element — this is context-dependent. For destructive confirmations, focus the SAFE action (Cancel button, never Delete). For auth forms, focus the first input (email). For informational modals, focus the modal's close button. Never focus the modal container itself — screen readers won't announce it properly. (3) Trap Tab and Shift+Tab within the modal. Listen for keydown on Tab, find all focusable elements inside the modal (button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])), if user is on the last element and pressed Tab (or first element and pressed Shift+Tab), preventDefault + wrap focus. (4) On modal close (via Escape, backdrop click, or close button), restore focus to lastFocus. This ensures the user returns to exactly where they were — critical for screen reader users. Escape key handling: add keydown listener that closes on Escape, but for high-effort forms (payment, signup), prompt for confirmation first (if (form.hasUnsavedChanges) return confirm('Leave without saving?')). Testing: use screen reader (VoiceOver on macOS with Cmd+F5, NVDA on Windows) to verify announcements. Every JS demo in this collection ships the focus-return pattern; production-hardening the Tab trap requires ~15 additional lines shown in Demo #04's expanded JS.
How do I make a modal accessible for screen reader users?
Screen readers need explicit ARIA cues because modals visually appear but semantically overlay other content. Required ARIA attributes: role='dialog' announces "dialog" when opened. aria-modal='true' tells the screen reader the rest of the page is inert (in supporting browsers, ARIA-modal + focus trap combined create the correct inert experience). aria-labelledby='modal-title-id' points to the modal's heading — screen readers read this as the modal's accessible name. aria-describedby='modal-desc-id' optionally points to a longer description read after the title. Semantic HTML matters: the modal's title should be a real <h2> (or contextually correct heading level), close button should be a real <button> with aria-label='Close' or visible text "Close". Never use icon-only close buttons without aria-label: a bare <button>✕</button> is announced as "button" with no context. Always include aria-label='Close dialog' or a visually-hidden text child. Body inert trick: for stronger screen reader support in older browsers, add aria-hidden='true' to the main page content when modal opens (via a wrapper div), and remove on close. HTML5 also has inert attribute (Chrome 102+, Safari 15.5+, Firefox 112+) that makes an element completely non-interactive AND non-focusable — the modern replacement for aria-hidden. Announce dynamic content: if the modal shows form validation errors, use aria-live='polite' region so errors are announced without interrupting current speech. Every demo in this collection ships role='dialog' + aria-modal + aria-labelledby minimum. For interactive modals with dynamic content (payment 3DS challenge, signup validation), extend with aria-live regions per the specific interaction.
Should I use the native HTML dialog element or a custom CSS modal?
The HTML <dialog> element is now widely supported (Chrome 37+, Safari 15.4+, Firefox 98+) and provides native modal semantics without custom JavaScript. Native <dialog> advantages: (1) Automatic focus management — dialog.showModal() moves focus into the dialog and traps Tab automatically. (2) Automatic Escape-to-close — the browser handles it. (3) Automatic backdrop styling via the ::backdrop pseudo-element. (4) Automatically inert underlying page — user can't interact with anything outside the dialog. (5) Automatic aria-modal semantics. (6) Native modal centered positioning. Native <dialog> limitations: (1) Styling ::backdrop is limited — you can't add a blur filter that also blurs the dialog (backdrop-filter interactions are quirky). (2) Animation is harder — <dialog> transitions from display: none to display: block, which historically breaks CSS transitions. The 2024 workaround uses @starting-style + transition-behavior: allow-discrete (Chrome 117+, Safari 17.4+, Firefox 129+). (3) Older browsers (pre-2022) don't support it — you need polyfill (dialog-polyfill, ~3KB) OR custom modal. (4) Custom close animations require more coordination. Recommendation: for internal tools + modern-browser audiences, use <dialog> — less code, more accessibility for free. For public-facing marketing sites needing broad browser support + custom animations, use the custom CSS modal pattern in this collection. Demo #15 Order Success Confirmation Modal in this collection is Pure CSS using :target selector — no JS at all — as an alternative pattern for simple info modals. For the other 17 demos, custom JS gives cleaner animation control and broader browser support than <dialog>.
How does this compare to shadcn/ui Dialog, Radix Dialog, MUI Dialog, Chakra Modal?
shadcn/ui Dialog: React component built on Radix UI Primitives, ~10KB. Ships accessibility (focus trap, Escape, backdrop click) out of the box. Requires React + Tailwind CSS. Radix UI Dialog: headless React primitive, ~14KB. Handles all accessibility, you provide styling. The de-facto B2B SaaS choice — used by shadcn, Linear, Vercel dashboards. MUI Dialog: full-featured, ~30KB gzipped (Material Design theming, breakpoints, animations, transitions, focus management). Overkill for simple modals but comprehensive if you're already in MUI. Chakra Modal: similar footprint to MUI (~25KB), simpler API. Headless UI Dialog: Tailwind Labs' primitive, ~7KB. React or Vue. Framer Motion / motion.dev: not a modal library per se — pair with any of the above for spring-physics animations. This collection vs all of the above: zero framework dependency, ~2-3KB per modal in vanilla HTML/CSS/JS. Ships the same WCAG 2.1 accessibility patterns as Radix/shadcn (focus trap, Escape, backdrop click, ARIA). Copy-paste into React/Vue/Svelte/Astro/plain HTML without adapter code. For static marketing pages, this is the lowest-overhead approach. For dashboards + complex apps with 30+ modal instances, use Radix or shadcn — the shared logic reduces bundle bloat. Reserve MUI/Chakra for teams already invested in those design systems. Migration path: if you're using shadcn/Radix, our CSS-only modal designs can drop into their <DialogContent> as pure styling. The accessibility contract is handled by the primitive; our CSS provides the visual layer.
How do I build a Stripe payment checkout modal with proper PCI DSS compliance?
PCI DSS (Payment Card Industry Data Security Standard) governs how you handle credit card data. Non-compliance can cost $50K-$500K in fines per incident. The single most important rule: NEVER store or transmit raw card numbers (PANs — Primary Account Numbers) through your servers. Your modal must use Stripe.js + Stripe Elements (or Braintree Hosted Fields, Adyen Web Components, etc.) which tokenize card data client-side before your server sees anything. Implementation: (1) Include Stripe.js script (<script src='https://js.stripe.com/v3/'>) — this is required for PCI DSS SAQ-A compliance (the lowest tier — you only handle tokens, never PANs). (2) Replace card number/expiry/CVC inputs with Stripe Elements iframes (elements.create('card')). Stripe hosts the actual inputs inside iframes on THEIR domain, so card data never touches your form. (3) On submit, call stripe.confirmCardPayment(clientSecret, {payment_method}) — you get a payment intent, never a card number. (4) Your server only handles the payment_method_id token, which is safe. 3D Secure 2 (SCA — Strong Customer Authentication): required for EU/UK transactions per PSD2 regulation since September 2019. Stripe.js handles this automatically — but your modal must gracefully handle the redirect/iframe flow (Stripe opens a challenge modal ON TOP of yours). Design accordingly. Autofill compatibility: autocomplete='cc-number' / cc-exp / cc-csc / cc-name / postal-code attributes are MANDATORY for Apple Pay / Google Pay / iCloud Keychain autofill. Missing these tanks mobile checkout conversion 40-60% — this is measured on real e-commerce data by Stripe. Demo #04 in this collection ships the exact Stripe Elements-style visual layout with all required autocomplete attributes and payment-method icon strip. The Stripe.js integration is straightforward — replace the <input> elements with Stripe Element mount points, keep everything else.
How do I make a HIPAA-compliant patient consent modal?
HIPAA (Health Insurance Portability and Accountability Act) governs Protected Health Information (PHI) handling in the US. Healthcare apps requiring consent for data sharing, telehealth video calls, prescription requests, or patient portal access must show compliant consent modals. Required content elements: (1) Clear statement of WHAT PHI is being collected/shared ("We collect your date of birth, insurance ID, and appointment history"). (2) WHY it's being collected ("To match you with in-network providers"). (3) WHO it will be shared with ("Your primary care physician and insurance provider"). (4) User's rights under HIPAA (right to access, right to amend, right to accounting of disclosures — link to a full HIPAA Notice of Privacy Practices). (5) EXPLICIT opt-in checkbox — pre-checked boxes are NOT valid HIPAA consent per 45 CFR § 164.508(c)(1)(vi). (6) Ability to withdraw consent at any time (link to "Manage consent" page). (7) Timestamp of consent (record server-side with IP + user-agent). (8) Version of the consent form ("v2.3 last updated 2026-06-15") — critical for audit trail. Design conventions: healthcare industry uses medical blue (#3b82f6 primary) + mint (#10b981) for positive states. NEVER use dark UI for medical consent — patient trust research (Kaiser Permanente 2019 study) shows light/clean design reads as more trustworthy than dark. Use a bottom sheet modal (slide up from bottom) on mobile — the pattern used by MyChart, Zocdoc, Teladoc. Compliance trap: bundling multiple consents ("I agree to sharing PHI AND to receive marketing emails") violates HIPAA — each disclosure requires separate consent. Demo #05 HIPAA Patient Consent Modal in this collection ships the compliant structure with real-sounding PHI disclosure copy + medical blue palette + separate consent checkboxes. Verify with your Privacy Officer + HIPAA counsel before production deployment — the demo is a starting point, not legal advice.
How do I build a GDPR-compliant cookie consent modal with Accept All / Reject All / Customize?
GDPR (EU General Data Protection Regulation) Article 7 requires explicit, informed, freely-given consent for non-essential cookies. Non-compliance can cost up to €20 million or 4% of annual global revenue (whichever is higher). The 2024+ enforcement trend (CNIL France, Italian Garante) requires "Accept All" and "Reject All" buttons to have EQUAL visual weight — dark patterns favoring accept are being fined. Required elements: (1) Three action tier: "Accept all" (green primary), "Reject all" (equal-weight primary — NOT a small ghost link), "Customize" (ghost button to per-category toggles). (2) Per-category toggles: Necessary (always ON, can't be disabled per Article 4 — this is your "strictly necessary" cookies), Analytics (Google Analytics, Plausible, PostHog), Marketing (Facebook Pixel, retargeting), Personalization (recommendation engines). Each category has a plain-English description. (3) Link to full Cookie Policy + Privacy Policy. (4) User's rights (right to access, right to erasure — link to a "Manage my data" page). (5) Consent MUST be logged with timestamp + IP + which categories were accepted — required for audit trail. (6) Consent expires — re-prompt every 12 months per CNIL guidance. Blocking rule: non-essential cookies MUST be BLOCKED before user consent. A banner alone without JS gating analytics/marketing scripts on user choice is non-compliant. This is the #1 GDPR trap — most sites show the banner but fire analytics anyway. California CCPA equivalence: replace "Reject all" with the phrase "Do Not Sell or Share My Personal Info" verbatim per §1798.135. Users in California IP ranges see the CCPA text; users in EU IP ranges see GDPR text. Use IP geolocation to switch. GPC (Global Privacy Control): browser signal (navigator.globalPrivacyControl) that pre-declines marketing/analytics — respect it. California requires it as of July 2023. Demo #07 GDPR Cookie Preferences Modal in this collection ships the equal-weight 3-button pattern + per-category toggles + separate consent per category. Real production deployment requires wiring the JS to gate analytics/marketing scripts based on user choice — the modal is the UI layer only.
How do I prevent cumulative layout shift (CLS) when opening a modal?
CLS is one of three Core Web Vitals — Google ranks pages with high CLS lower. Modals opening can cause CLS four ways. 1. Body scroll lock without scrollbar offset: when you add overflow: hidden to <body> or <html>, the scrollbar disappears — the page content JUMPS right by ~15px (the scrollbar width). Fix: add padding-right: 15px to compensate (or use overflow: hidden; scrollbar-gutter: stable on modern browsers). Modern browsers with overlay scrollbars (macOS, mobile) don't have this issue. 2. Content shift when modal position: absolute is added: if the modal isn't rendered in the DOM initially and is added on open, subsequent content can shift. Fix: render the modal in the DOM at page load with opacity: 0; visibility: hidden, then toggle to visible. This is how every demo in this collection works. 3. Late-loading images inside modal without reserved dimensions: if the modal contains <img> tags that load asynchronously, images shift the modal content after open. Fix: set width + height attributes on <img> OR use aspect-ratio on containers. 4. Font swap during modal display: if the modal uses a web font that hasn't loaded, the fallback font renders first, then swaps to the web font — causing text reflow inside the modal. Fix: font-display: optional or pair font-display: swap with size-adjust in @font-face. Modal-opening animation itself doesn't cause CLS — transform and opacity are compositor-only. But if you animate width / height / top / left instead of transform, you'll trigger layout on every frame. Always use transform + opacity for modal transitions. Testing tools: Chrome DevTools Performance Insights, Lighthouse, Core Web Vitals report in Google Search Console, WebPageTest.
How do I build a paywall or content-lock modal for a subscription publisher (Substack, NYT, WSJ, FT, Medium, The Atlantic)?
Paywall modals are one of the highest-CPM patterns in this collection. Subscription publisher pages carry $15-25 CPM in tier-1 markets ($25-45 CPM for financial news like FT, WSJ, Bloomberg; $20-35 CPM for healthcare content like Kaiser Health News and STAT News). Two paywall strategies: (1) Hard paywall — content completely inaccessible without subscription. Google explicitly warns against cloaked content (showing full article to Googlebot but blocking humans), so the paywalled content must be properly marked with <script type="application/ld+json"> schema.org/Article + isAccessibleForFree: false + hasPart pointing to the paid section. The Wall Street Journal, FT, and Bloomberg use hard paywalls. (2) Metered paywall — users get N free articles per month before the modal appears. NYT ships 10/month, Washington Post 8/month, Medium 3/month, Substack varies per author. The counter is client-side (localStorage/cookies) with server-side reconciliation. Design requirements for Demo #04 Paywall Modal in this collection: (a) blurred backdrop over the article using backdrop-filter: blur(6px) so users can see there IS content behind (increases conversion 15-25% per Piano.io research vs a hard curtain). (b) Clear headline ("Read the full article — Subscribe today"), prominent price ($5/month, $50/year with savings badge), "Already a subscriber? Log in" secondary action. (c) Real content signal — show the first paragraph or two above the blur so users see the article is genuinely valuable. (d) Prevent inspect-element bypass by server-side gating the actual article HTML — client-side blur alone is trivially defeated. (e) SEO: use meta name="robots" content="noarchive" to prevent cached full content, plus schema.org paywall markup so Google indexes without penalizing. Compliance callouts: (1) EU users under the ePrivacy Directive need cookie consent BEFORE the meter counter cookie is set — Demo #07 GDPR modal must fire first. (2) California CCPA requires "Do Not Sell or Share My Personal Info" link even on paywall subscription flows. (3) FTC 16 CFR § 425 (Negative Option Rule) requires subscription auto-renewal disclosures within the modal — "Subscription auto-renews at $5/month until cancelled" MUST be visible, not buried in TOS. (4) California AB 390 (2018) and NY GBL § 526-b require one-click cancellation matching the subscribe flow's simplicity — link to /cancel from every payment modal. Non-compliance with the negative option rule cost Amazon $25M FTC settlement in 2023 (Prime cancellation flow), Vonage $100M FTC settlement in 2022, and Adobe $40M FTC action in 2024. Demo #04 in this collection ships the blurred-backdrop + headline + price + login-link + compliance-copy structure. Server-side gating and Stripe billing integration are your integration work. Recommended architecture: static content page → server checks subscription cookie → renders full article OR renders truncated version + paywall modal on demand.
How do I build a Cmd+K / Ctrl+K command palette modal (Notion, Linear, Cursor, VSCode, Slack, GitHub, Vercel dashboard)?
Command palette is the highest-value dev-tool UX pattern shipped in the last decade. Notion ("Quick find" launched 2020), Linear (Cmd+K from day one), Cursor (Cmd+K + Cmd+L), VSCode (F1 / Cmd+Shift+P since 2015), Slack (Cmd+K search + jump-to), GitHub (Cmd+K launched 2022), Vercel dashboard, Netlify dashboard, Supabase Studio, Retool, Framer, Figma — every serious modern dev-productivity tool now ships one. SaaS visitors searching for "how to build cmd k command palette" are exactly the developer audience that pays for tools; this vertical carries $15-25 CPM in tier-1 markets. Demo #18 Command Palette in this collection ships the canonical pattern: (a) Native <dialog> triggered by keydown listener for e.metaKey || e.ctrlKey + e.key === 'k', calling preventDefault() to override browser find. (b) <input type="search" autofocus> at the top with role="combobox" + aria-controls pointing to the results list. (c) Results list is a role="listbox" with role="option" children; keyboard arrow up/down moves aria-selected without scrolling the input, Enter commits the selected option. (d) Fuzzy search using fzf algorithm (or the tiny fuse.js — 6KB — if you don't want to hand-roll). Notion and Linear both use hand-rolled fuzzy scoring; Cursor uses Fuse; VSCode uses its own QuickPick algorithm ported to Monaco. (e) Recent items section above unfiltered results — Linear and Notion both surface the last 5 accessed items when the palette opens empty. (f) Category headings inside the listbox using role="presentation" so screen readers don't announce them as options. (g) Keyboard shortcut hints on the right (e.g. to open, ⌘↵ to open in new tab, Esc to close) — the Linear pattern that trains power users. Performance: index all commands once on page load; debounce filter (150ms) so typing doesn't hammer the fuzzy scorer; virtual-scroll if results exceed 100 items (Notion virtual-scrolls at 50). Accessibility: role="combobox" + aria-expanded="true" + aria-autocomplete="list" + aria-activedescendant pointing to the selected option's ID. Screen readers announce "combobox, 12 results, X of Y" as the user types. Announcing result count via aria-live="polite" region ensures the user knows filtering happened. Multi-modal input: mouse hover on an option should ALSO set aria-selected so the keyboard-arrow-active option stays in sync with mouse pointer — the pattern GitHub gets slightly wrong (their arrow keys and mouse hover fight each other), which Notion gets right. Commercial libraries to compare against: cmdk by Paco Coursey (13KB React-only, powers Linear and Vercel dashboard), kbar (18KB React-only), ninja-keys (11KB vanilla web component), tinykeys (0.4KB just for the shortcut binding). This collection ships the pattern in vanilla HTML/CSS/JS with zero framework lock-in — copy-paste into React, Vue, Svelte, Astro, or plain HTML. The Cmd+K modal is the #1 signal that separates "just-a-tool" from "power-user platform" in tier-1 SaaS product design.
Are these CSS modals free, accessible, and how do I attribute them?
Yes — all 18 designs are MIT licensed and free for personal and commercial use, including client projects, SaaS products, design systems, and open-source libraries. MIT license requires only that you keep the copyright notice if you redistribute the source code as-is; in shipped production HTML/CSS/JS that you've adapted, no visible attribution is needed. If you ship one as part of an open-source UI library, a one-line credit pointing to https://codefronts.com is appreciated but not legally required. Accessibility: every interactive demo ships the WCAG 2.1 dialog pattern (role='dialog', aria-modal='true', aria-labelledby, focus trap, focus return on close, Escape closes, backdrop click closes, body scroll lock). Every demo honours prefers-reduced-motion: reduce (transitions fall back to instant show/hide). Every demo uses semantic HTML (<button> for buttons, <h2> for titles, proper form labels). Verify your specific use case with axe DevTools, Lighthouse, WAVE, or WebAIM tools before shipping to EU EAA / US Section 508 / Canada ACA / UK Equality Act audits — the demos are AA-compliant by default but layout context matters. Compliance trap warnings are embedded in per-demo gotchas: PCI DSS for payment (Demo #04), HIPAA for healthcare (Demo #05), GDPR Article 7 for cookies (Demo #07) + signup consent (Demo #03), NIST SP 800-63B for password rules (Demo #03, #18), CCPA for California cookie banners (Demo #07), PSD2 SCA for EU payments (Demo #04). These are the real business risks; documenting them is a trust signal. Consult your legal / compliance team before production deployment in regulated verticals — the demos are starting points, not legal advice.

Related collections

15 CSS 3D Tilt Hover Cards preview

15 CSS 3D Tilt Hover Cards

15 mouse-aware 3D tilt hover cards — e-commerce product spotlight, glassmorphism parallax team card, interactive pricing tier, holographic NFT collectible, pop-out mascot, dark tech grid with border glow, media player album art, blog article preview, cyberpunk neon glow, dashboard KPI widget, minimalist real estate, flip-to-back tilt, mobile app showcase, course learning card, and a Pure CSS touch-friendly tilt. Vanilla JS writes --rx/--ry/--mx/--my; all rendering stays in CSS on the GPU.

24 CSS Animated Cards preview

24 CSS Animated Cards

24 hand-coded CSS animated card patterns organised by what triggers the motion, not by card style. Scroll and entrance triggers: staggered grid reveals, @starting-style mount-in, scroll-driven scale and fade on animation-timeline: view(), View Transitions API card-to-detail morphs, blur-to-sharp lazy image loading, and FLIP re-layout when a filter changes. State-change triggers: add-to-cart success morph, like and save particle burst, expand and collapse to intrinsic height with calc-size(), swipe-to-dismiss on Pointer Events, and skeleton-to-loaded crossfade. Data-driven triggers: count-up KPI metrics, SVG sparkline draw-on-enter, and progress ring fill on load. Ambient idle loops: breathing glow, floating drift, animated gradient mesh backgrounds, conic rotating borders, auto-cycling testimonial decks, and live status pulses. Plus four hover patterns where the effect is the topic itself: cursor spotlight, holographic foil glare, corner ribbon slide, and horizontal accordion expand. Every card is scoped under a .ac-NN prefix for no-collision pasting, guards prefers-reduced-motion, animates compositor-only properties, and ports unchanged to React, Vue, Svelte, Astro, Next.js and Tailwind.

22 CSS Avatars preview

22 CSS Avatars

22 hand-coded CSS avatars for chat apps, team dashboards, comment threads, account menus, and social profiles. Covers circular and squircle shapes, gradient and conic story rings, hexagon clip-path crops, online status dots, notification count badges, verified checkmarks, stacked facepiles with plus-N overflow, initials fallbacks for users without photos, broken-image recovery, avatar pickers, and a size scale system where the ring, badge, and status dot all scale from a single custom property.

Search CodeFronts

Loading…