Skip to content

Tailwind CSS - Sepia

Tailwind CSS provides utility classes to apply a sepia filter to an element, giving it a warm, brownish monochrome tone reminiscent of early photography. This is part of a larger set of filter utilities that includes grayscale, blur, and brightness.

Use the sepia and sepia-0 utilities to apply or remove the sepia effect.

ClassCSS Properties
sepiafilter: sepia(100%);
sepia-0filter: sepia(0);

The true power of Tailwind comes from combining utilities with modifiers. You can apply filters conditionally, such as on hover, or use arbitrary values for fine-tuned control.

  • Conditional Application: Add prefixes like hover, focus, or dark to apply the filter in different states. For example, hover:sepia will apply the filter only when the user’s cursor is over the element.
  • Arbitrary Values: For custom sepia amounts, use square bracket notation. For example, sepia-[.65] applies a 65% sepia filter.
Section titled “Practical Example: Interactive Photo Gallery”

This example demonstrates an interactive image card that starts with a sepia filter and transitions to full color on hover. This creates a modern, engaging user experience.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tailwind Sepia Filter</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-slate-100 flex items-center justify-center h-screen">
<div class="p-8">
<h1 class="text-3xl font-bold text-slate-800 mb-6 text-center">Interactive Photo Card</h1>
<div class="relative w-72 h-96 rounded-lg overflow-hidden shadow-xl group">
<img
src="https://placehold.co/600x800/a8a29e/44403c"
alt="A placeholder image of a landscape."
class="w-full h-full object-cover sepia group-hover:sepia-0 transition-all duration-500 ease-in-out"
/>
<div class="absolute bottom-0 left-0 p-4 bg-gradient-to-t from-black/60 to-transparent w-full">
<h3 class="text-white font-bold text-xl">Vintage Landscape</h3>
<p class="text-slate-300 text-sm">Hover to see in full color</p>
</div>
</div>
</div>
</body>
</html>

While filters are visually appealing, they alter colors and can reduce contrast. Use them thoughtfully to ensure your content remains readable and accessible to all users, especially those with color vision deficiencies. The sepia filter is generally best suited for decorative images rather than informational content.