Advertisement

Cinematic Black Magic Volume Knob

| by Vladimir | 2 min read | code by LukyVj
A11y Ready Advanced

Tech & Dependencies

HTML SCSS JavaScript

Features

  • CSS @property
  • SVG Filters
  • Particle System

Browser Support

Chrome 118+ Edge 118+ Firefox 120+ Safari 17.4+ (Partial)

Core

This Cinematic Black Magic Volume Knob pushes the boundaries of modern CSS, creating a tangible, high-fidelity control element. It combines a standard range input with advanced CSS Houdini features like @property and wide-gamut P3 colors. The result is a glowing, liquid-like interface where turning the dial triggers a cascade of particles and dynamic lighting effects, perfect for premium audio applications or dashboards.

Core Technique

The component is a masterclass in layering. The functional logic relies on a simple JavaScript one-liner that updates a --value CSS variable. The visual heavy lifting is done by CSS:

  1. Invisible Driver: A standard <input type="range"> sits on top of the component with opacity: 0. This handles all user interaction (drag, click, keyboard support) for free.
  2. Wide Gamut Glows: It uses oklch() and color(display-p3 ...) wrapped in color-mix() to generate intense, neon-like gradients that change luminance based on the knob’s value.
  3. Liquid Texture: An SVG <filter> with feTurbulence is applied to the glow rings via CSS. This distorts the background, creating a “smoke” or “liquid” effect inside the glass.

Customization

The “magic” is controlled via CSS variables in the SCSS. The most important one to tweak is the base glow color, defined in the :root.

@supports (color: color(display-p3 0 0 0)) {
  :root {
    /* 
       P3 Color Space Format (Red, Green, Blue alpha) 
       Format: 0.0 to 1.0
    */
    /* Orange (Default) */
    --glow-color-p3: 0.99 0.71 0.18;
    
    /* Try Purple */
    /* --glow-color-p3: 0.23 0.07 0.99; */
    
    /* Try Red */
    /* --glow-color-p3: 0.7 0.09 0.2; */
  }
}

To adjust the particle trail intensity, you modify the SCSS loop that generates the shadows.

/* Config */
$spacing: 100px;
$color: var(--glow-color);

/* Generates random box-shadows for particles */
@function particles($max) {
   $val: 0px 0px $color;
   @for $i from 1 through $max {
      $val: #{$val},
      random($spacing*1.5)+px random($spacing*1.5)+px $color;
   }
   @return $val;
}

Tips

1. Performance Warning: This component is visually heavy. It uses will-change: transform, filter, background, which forces GPU promotion. While this ensures smooth animation, placing 20 of these on a single page might crash a mobile browser.

2. Browser Support Nuances: The code uses color-mix and @property.

  • Firefox: Supports the colors but might render the SVG turbulence filter differently than Chrome.
  • Safari: Has historically struggled with combining mix-blend-mode and complex SVG filters. Test on iOS devices.
  • Fallback: Always keep the @supports query to provide a fallback color for screens that don’t support P3 gamut.
Advertisement