CSS Duotone Image

Maps any photo to two brand colors with blend modes, then shows the original image on hover.

  • duotone
  • mix-blend-mode
  • image filter
  • brand colors
  • photo effect
  • hover
HTML
<div class="duotone">
  <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 40'%3E%3Crect width='60' height='40' fill='%23bae6fd'/%3E%3Ccircle cx='14' cy='11' r='6' fill='%23fde047'/%3E%3Cpath d='M0 40V30l15-6 15 5 15-7 15 6v12z' fill='%2334d399'/%3E%3Cpath d='M36 31l5-15 5 15zM45 32l4-11 4 11zM8 36l4-12 4 12z' fill='%23047857'/%3E%3C/svg%3E" alt="Green hills and pine trees on a sunny day" width="240" height="160">
</div>
CSS
.duotone {
  --light: #fde68a;
  --dark: #9d174d;
  position: relative;
  width: 240px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--light);
  isolation: isolate;
}

.duotone img {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(1) contrast(1.1);
  mix-blend-mode: multiply;
}

.duotone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--dark);
  mix-blend-mode: lighten;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.duotone:hover img {
  filter: none;
  mix-blend-mode: normal;
}

.duotone:hover::after {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .duotone::after {
    transition: none;
  }
}

About this CSS Duotone Image

This CSS Duotone Image is 43 lines of pure CSS (0.7 KB) with no JavaScript and no dependencies. It uses transitions, filters, blend modes and custom properties. 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

Change these custom properties to restyle the duotone image without touching the rest of the CSS:

PropertyDefault
--light#fde68a
--dark#9d174d

How to use this duotone image

  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 .duotone 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