Blur and brightness filters help you change how things look on your webpage. Blur makes things fuzzy, and brightness makes things lighter or darker.
Blur and brightness filters in Tailwind
Start learning this pattern below
Jump into concepts and practice - no test required
blur-{size}
brightness-{percentage}Sizes for blur can be like blur-sm, blur, blur-md, blur-lg, blur-xl, blur-2xl.
Brightness uses percentages like brightness-50 (darker) to brightness-150 (brighter).
<div class="blur-sm">This text is slightly blurry.</div><img class="brightness-125" src="photo.jpg" alt="Bright photo">
<div class="blur-lg brightness-75">Blurred and darker box</div>This page shows three examples: a blurred background image with text on top, a button that gets brighter when hovered, and a box that is slightly blurred and brighter.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Blur and Brightness Filters</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center justify-center min-h-screen gap-8 bg-gray-100 p-6"> <h1 class="text-2xl font-bold">Blur and Brightness Filters Example</h1> <div class="relative w-64 h-40"> <img src="https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=400&q=80" alt="Nature" class="w-full h-full object-cover rounded-lg blur-md"> <p class="absolute inset-0 flex items-center justify-center text-white text-lg font-semibold">Blurred Background</p> </div> <button class="px-6 py-3 bg-blue-600 text-white rounded-lg brightness-90 hover:brightness-125 transition"> Hover me to brighten </button> <div class="w-64 h-24 bg-green-400 rounded-lg blur-sm brightness-110 flex items-center justify-center text-white font-medium"> Slightly blurred and brighter box </div> </body> </html>
Use transition classes to make brightness changes smooth on hover.
Blur can affect readability, so use it carefully especially on text.
Brightness values below 100% make things darker, above 100% make them brighter.
Blur and brightness filters change how elements look by making them fuzzy or lighter/darker.
Tailwind uses simple class names like blur-md and brightness-125 to apply these effects.
Combine these filters with hover and transition for nice interactive effects.
Practice
blur-sm do to an element?Solution
Step 1: Understand the
Theblur-smclassblur-smclass applies a small blur filter, making the element look fuzzy.Step 2: Compare with other effects
Brightness changes lightness, shadow adds shadow, and gray changes color, so these are different effects.Final Answer:
It makes the element slightly blurry. -> Option AQuick Check:
Blur = fuzzy effect [OK]
- Confusing blur with brightness
- Thinking blur adds shadow
- Assuming blur changes color
Solution
Step 1: Recall Tailwind brightness syntax
Tailwind usesbrightness-followed by a number like 125 for 125% brightness.Step 2: Check each option
Onlybrightness-125matches Tailwind's correct syntax; others are invalid.Final Answer:
brightness-125 -> Option DQuick Check:
Correct class = brightness-125 [OK]
- Using dot instead of dash
- Omitting dash between brightness and number
- Using wrong prefix like bright
<div class="blur-md brightness-75">Hello</div>
Solution
Step 1: Analyze the blur-md class
blur-mdapplies a medium blur, making the text fuzzy.Step 2: Analyze the brightness-75 class
brightness-75reduces brightness to 75%, making the text darker.Final Answer:
The text will be blurry and darker than normal. -> Option CQuick Check:
Blur = fuzzy, brightness 75% = darker [OK]
- Mixing up brightness values (higher means brighter)
- Assuming blur sharpens text
- Ignoring combined effects
<img class="blur-4xl brightness-150" src="photo.jpg" alt="Photo" />
Solution
Step 1: Check blur class validity
Tailwind supports blur sizes like sm, md, lg, xl, 2xl, 3xl but not 4xl.Step 2: Verify brightness and attributes
Brightness-150 is valid (150%), alt attribute is present, src is correctly quoted.Final Answer:
The classblur-4xldoes not exist in Tailwind. -> Option AQuick Check:
Invalid blur class = blur-4xl [OK]
- Assuming any 'xl' size exists
- Thinking brightness max is 100%
- Ignoring alt attribute importance
<button class="?">Click Me</button>
Solution
Step 1: Understand the base state
The button starts blurry and darker withblur-lg brightness-75.Step 2: Understand the hover state
On hover, blur is removed (blur-none) and brightness increases to 125% (brightness-125), making it clearer and brighter.Step 3: Confirm transition for smooth effect
transitionenables smooth change on hover.Final Answer:
blur-lg brightness-75 hover:blur-none hover:brightness-125 transition -> Option BQuick Check:
Hover removes blur and brightens = blur-lg brightness-75 hover:blur-none hover:brightness-125 transition [OK]
- Reversing hover effects
- Forgetting transition class
- Using same blur and brightness on hover
