8 CSS & JavaScript Snippets for Creating Beautiful Bokeh Effects

Bokeh has long been a celebrated photographic style. In simplistic terms, it features a primary focus on a subject and a gently blurred background. The technique is both beautiful and a sure way to grab a user’s attention.

But what if you want to implement a Bokeh aesthetic without photography? There are some unique methods for doing so.

Web designers are using CSS and JavaScript to create all manner of Bokeh-inspired effects. You’ll find the familiar blurry lens flare from photos. But there’s also the addition of movement, generative UIs, and plenty of artistic license being used.

Here are eight examples of Bokeh effects powered by code. There may be some similarities on the surface. But look closely, and you’ll also discover how detailed these presentations are. Let’s get started!


  • Border Effects
  • Cursor Effects
  • Flame Effects
  • Glassmorphism Effects
  • Halftone Effects
  • Liquid Effects
  • Metallic Effects
  • Neumorphic Effects
  • Neon Effects
  • Noise Effects
  • Pattern Effects
  • Parallax Effects
  • Pixelated Effects
  • Repelling Effects
  • Scroll Effects
  • Shadow Effects
  • Skeuomorphic Effects
  • Transition Effects

Bokeh Lighting Background by Wakana Y.K.

In photography, Bokeh often adds depth to an image. This snippet takes the concept to an entirely different level. Three.js is used to add some slick 3D animation. Plus, users can drag the background to change the perspective.

See the Pen Bokeh Lighting Background by Wakana Y.K.

Bokeh CSS Doodle by Crystal S

A combination of CSS Grid, animation, and filters bring this presentation to life. The movement is noticeable without becoming a distraction. This makes it a nice solution for a hero area or even a page background. Clicking on the canvas generates a new scene with the help of JavaScript.

See the Pen Bokeh CSS Doodle by Crystal S

Animated Bokeh Lava Lamp Canvas by smpnjn

This example of Bokeh combines the effect with the gooey brilliance of a lava lamp. Bubble-like lens flares fade in and out of focus, while the movement remains serene. The result is a scene that creates a calming vibe.

See the Pen Animated Bokeh Lava Lamp Canvas by smpnjn

Hex Bokeh Effect by Will Boyd

Here’s a decidedly different take on Bokeh. First, you’ll notice a static-looking background that features hexagons. But start scrolling, and you’ll discover a scattered parallax effect. The snippet also uses a clever bit of generative UI to create a new scene upon each page refresh.

See the Pen Hex Bokeh by Will Boyd

Bokehlicious with CSSby Andy Fitzsimon

If you’re looking for subtle beauty, this snippet fits the bill. True to form, it emphasizes the foreground text. Meanwhile, colorful blobs move quietly in the background. SVG and CSS combine to add an atmospheric touch.

See the Pen bokehlicious by Andy Fitzsimon

Canvas Bokeh Effect by Aaron Silber

You may notice that most of the examples we’ve shared have a dark color scheme. But this one is proof that a bright palette can also be compelling. Once again, subtlety rules as dots gently fade in and out. It’s nothing fancy – but that’s the point.

See the Pen Canvas Bokeh Effect by Aaron Silber

Snowing Bokeh by Preetesh Jain

This snowy snippet can convey an array of emotions – from seasonal to noir. The black-and-white color scheme also provides a different twist on the aesthetic. The greatest concentration of white is at the bottom, yet it’s hard not to focus on the darker dots descending from the top.

See the Pen Snowing Bokeh by Preetesh Jain

Refreshing CSS Bokeh Effect by Nayra Rodrguez

Does your project have some flexibility when it comes to color? Then this snippet is worth checking out. Each click or refresh paints a new scene – including the color palette. The slow-moving orbs and muted tones won’t distract from your content.

See the Pen Untitled by Nayra Rodrguez

Bring Bokeh into Focus Through Code

Implementing Bokeh effects is a surefire way to add some artistic flair to your website. And the snippets above demonstrate a variety of potential uses. You can create anything from subtle backgrounds to something big and bold.

What’s more, CSS and JavaScript allow for almost infinite customization. Colors, intensity, and speed of motion are just a few of the items that can be tweaked. From there, you can craft a presentation that fits the overall aesthetic of your page.

We hope you found this roundup inspiring! If you’d like to see even more examples of Bokeh in action, check out our CodePen collection.