Grain-On-Hover Photo
A copy-paste noise & grain component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Noise & GrainHTMLCSSany framework
Hover / Focus
Copy into your project
HTML
<!-- Grain-On-Hover Photo — static at rest, grain animates on hover/focus -->
<div class="nuda-ng2-hover-photo" tabindex="0">
<div class="nuda-ng2-hover-photo__img" aria-hidden="true"></div>
<div class="nuda-ng2-hover-photo__grain" aria-hidden="true"></div>
<span class="nuda-ng2-hover-photo__caption">Hover / Focus</span>
</div>CSS
.nuda-ng2-hover-photo {
position: relative;
width: 100%;
max-width: 220px;
height: 140px;
border-radius: 12px;
overflow: hidden;
cursor: pointer;
isolation: isolate;
outline: none;
}
.nuda-ng2-hover-photo__img {
position: absolute;
inset: 0;
background: linear-gradient(135deg,#2a2e12,#09090b 70%);
transition: filter .25s ease;
}
.nuda-ng2-hover-photo__grain {
position: absolute;
inset: -50%;
width: 200%;
height: 200%;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
background-size: 140px 140px;
opacity: 0;
mix-blend-mode: overlay;
pointer-events: none;
transition: opacity .2s ease;
}
.nuda-ng2-hover-photo__caption {
position: absolute;
left: 12px;
bottom: 10px;
z-index: 1;
font-family: ui-sans-serif,system-ui,sans-serif;
font-size: 12px;
font-weight: 600;
color: #fafafa;
text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.nuda-ng2-hover-photo:hover .nuda-ng2-hover-photo__grain,.nuda-ng2-hover-photo:focus-visible .nuda-ng2-hover-photo__grain {
opacity: .3;
animation: _nuda-ng2hoverphoto-shift .5s steps(5) infinite;
}
.nuda-ng2-hover-photo:hover .nuda-ng2-hover-photo__img,.nuda-ng2-hover-photo:focus-visible .nuda-ng2-hover-photo__img {
filter: brightness(.85) saturate(1.2);
}
.nuda-ng2-hover-photo:focus-visible {
box-shadow: 0 0 0 2px #e4ff54,0 0 0 5px rgba(228,255,84,.25);
}
@keyframes _nuda-ng2hoverphoto-shift {
0% {
transform: translate3d(0,0,0);
}
25% {
transform: translate3d(-8px,5px,0);
}
50% {
transform: translate3d(6px,-7px,0);
}
75% {
transform: translate3d(-5px,-3px,0);
}
100% {
transform: translate3d(0,0,0);
}
}
@media (prefers-reduced-motion:reduce) {
.nuda-ng2-hover-photo:hover .nuda-ng2-hover-photo__grain,.nuda-ng2-hover-photo:focus-visible .nuda-ng2-hover-photo__grain {
animation: none;
opacity: .18;
}
}
How to use Grain-On-Hover Photo
Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.
Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.