CSS Newsletter Signup

An email field with the subscribe button tucked inside, plus a focus ring around the whole thing.

  • newsletter
  • subscribe
  • email
  • input
  • button
  • inline
HTML
<form class="subscribe">
  <input type="email" placeholder="you@example.com" aria-label="Email address" required>
  <button type="submit">Subscribe</button>
</form>
CSS
.subscribe {
  display: flex;
  width: 100%;
  max-width: 340px;
  padding: 5px;
  border: 1px solid #e4e4e7;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 20px -12px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.subscribe:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

.subscribe input {
  flex: 1;
  min-width: 0;
  padding: 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #18181b;
  font: 15px system-ui, sans-serif;
}

.subscribe button {
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  background: #6366f1;
  color: #fff;
  font: 600 14px system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.2s ease;
}

.subscribe button:hover {
  background: #4f46e5;
}

.subscribe button:focus-visible {
  outline: 2px solid #312e81;
  outline-offset: 2px;
}

About this CSS Newsletter Signup

This CSS Newsletter Signup is 47 lines of pure CSS (0.9 KB) with no JavaScript and no dependencies. It uses transitions, box shadows, Flexbox and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #e4e4e7
  • #fff
  • #6366f1
  • #18181b
  • #4f46e5
  • #312e81

How to use this newsletter signup

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .subscribe class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback