Skip to content

Newsletter Popup Modal with Side Image

Tailwind CSS newsletter popup with a side photo, email validation, focus trap, dismiss memory and a thank-you state.

Also known as: newsletter popup, email signup modal, subscribe popup with image, newsletter subscription modal

Tailwind CSS Modals Responsive #email #form #modal #newsletter #popup

Newsletter Popup Modal with Side Image live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A newsletter signup popup built with Tailwind CSS and vanilla JavaScript, with a photo on one side and an email form on the other. It opens automatically over a blog post, can be dismissed in several ways, remembers the dismissal, and switches to a thank-you view after a simulated subscription. Use it on blogs, recipe sites and online shops to grow an email list.

How it works

The root is .tnp-newsletter. It holds sample article content, a "Get the newsletter" trigger marked data-tnp-open, a role="status" message (data-tnp-status) and the .tnp-overlay, which starts hidden. The overlay contains the dimmed .tnp-backdrop and the #tnp-dialog panel (.tnp-panel), a grid with md:grid-cols-5: the photo takes md:col-span-2 and the form md:col-span-3. On phones the photo becomes an h-40 banner above the form.

The script initializes every .tnp-newsletter on DOMContentLoaded. If the root has data-tnp-auto-open, the popup opens after data-tnp-delay milliseconds unless it was dismissed within the last data-tnp-remember-days days; the dismissal time is stored in localStorage under tnp-dismissed-at, wrapped in try/catch so the popup still works where storage is blocked. Opening locks page scroll, focuses the email field (data-tnp-autofocus) and traps Tab inside the dialog. Escape, the backdrop and every element with data-tnp-close close it and return focus. On submit the email is checked against a simple pattern; after an 800 ms simulated request the data-tnp-form-view is hidden and data-tnp-success-view is shown. style.css adds the tnp-fade and tnp-rise entrance animations.

Customization

  • data-tnp-delay on .tnp-newsletter: set e.g. 5000 to open the popup five seconds after page load; 0 opens it at once.
  • data-tnp-remember-days: how long a dismissal is respected, e.g. 30; set 0 to show it on every visit.
  • Remove data-tnp-auto-open to open the popup only from the data-tnp-open button.
  • The img inside #tnp-dialog: swap the photo; md:col-span-2 and md:col-span-3 control the image-to-form ratio.
  • bg-orange-700, text-orange-700 and bg-[#fbf6ef]: change the accent and the cream panel color to match your brand.
  • max-w-3xl on .tnp-panel: use max-w-2xl for a more compact popup.
  • The setTimeout in the submit handler of script.js: replace it with a fetch() call to your email provider or API.

Use cases

  • Blogs: a popup opens after a delay over an article to collect email subscribers
  • Recipe sites: a side photo makes the signup invitation feel inviting
  • Online shops: a thank-you view confirms the subscription after the email is validated
  • Content sites: the popup remembers dismissal for a set number of days so visitors are not nagged

Accessibility

The panel uses role="dialog", aria-modal="true", aria-labelledby="tnp-title" and aria-describedby="tnp-desc". Focus moves into the dialog on open, is trapped while it is open and returns to the trigger on close; Escape always closes. The trigger exposes aria-haspopup="dialog", aria-controls and an aria-expanded state. The email field has a visible label, autocomplete="email", and on invalid input gets aria-invalid="true" plus an error read from a polite live region. After subscribing, focus moves to the success heading. The close icon has a hidden text label, decorative icons are aria-hidden, and the entrance animations stop under prefers-reduced-motion: reduce.

Usage notes

The photo comes from Unsplash; replace it with your own image. Use one popup per page and keep the id values unique.

Newsletter Popup Modal with Side Image at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Modals
License
Free for personal and commercial use

Questions about this template

Can I use the Newsletter Popup Modal with Side Image code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Newsletter Popup Modal with Side Image – free Tailwind CSS modal template
Newsletter Popup Modal with Side Image · free Tailwind CSS modal template

More Modals

Multi-Step Wizard Dialog – free Bootstrap 6 modal template

Multi-Step Wizard Dialog

Bootstrap 6 Dialog wizard with three steps, a Stepper and progress bar, back/next buttons, per-step validation, Chips email invites and a review screen.

Image Lightbox Dialog – free Bootstrap 6 modal template

Image Lightbox Dialog

Dark Bootstrap 6 Dialog lightbox that opens gallery thumbnails large, with previous/next buttons, arrow-key and swipe navigation, captions and a photo counter.

Multi-Step Modal Dialog – free Tailwind CSS modal template

Multi-Step Modal Dialog

Tailwind CSS modal with a three-step wizard: template picker, validated details form and review, plus stepper, focus trap and Escape to close.

Product Quick View Modal with Photo – free Bootstrap 5 modal template

Product Quick View Modal with Photo

Bootstrap 5 product quick view modal with photo, rating, material and size options that update price and image, quantity stepper and add to cart.

Newsletter Popup Dialog – free Bootstrap 6 modal template

Newsletter Popup Dialog

Bootstrap 6 Dialog newsletter popup with a photo side, email signup with validation, a don't-show-again option, delayed auto-open and a confirmation state.

Fullscreen Dialog on Mobile – free Bootstrap 6 modal template

Fullscreen Dialog on Mobile

Dark Bootstrap 6 Dialog for notification settings that is centered on desktop, fullscreen on phones, with a scrollable body of switches and a sticky footer.