npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-liquid-glass-hook

v1.0.0

Published

React hook and component for WebGPU-based glass refraction effect — SDF refractive edge + CSS backdrop-filter blur

Readme

react-liquid-glass-hook

React hook and component for WebGPU-powered glass refraction — SDF refractive edge + CSS backdrop-filter blur.

npm version license

Features

  • SDF-based refractive edge — Real 2D refraction using signed distance functions, not bitmap masks
  • Fresnel highlights — Physically-inspired edge glow
  • Chromatic aberration — Subtle RGB split at the border
  • CSS blur for the body — Lightweight backdrop-filter for the inner area
  • Zero dependencies — Only React as peer dependency
  • Branchless shader — All GPU computations use mix/step/smoothstep, no if/for
  • TypeScript — Full type definitions included

Installation

npm install react-liquid-glass-hook

Requires Chrome 113+ or Edge 113+ with WebGPU enabled.

Quick Start

<Glass> component

import { Glass } from 'react-liquid-glass-hook';

function App() {
  return (
    <div style={{ background: 'linear-gradient(135deg, #1a1a2e, #16213e)' }}>
      <Glass>
        <h2>Hello Liquid Glass</h2>
        <p>This content is inside a glass panel.</p>
      </Glass>
    </div>
  );
}

useGlass() hook

import { useGlass } from 'react-liquid-glass-hook';

function MyCard() {
  const canvasRef = useGlass({ borderWidth: 6, refraction: 18 });

  return (
    <div style={{ width: 400, height: 300, borderRadius: 32, position: 'relative' }}>
      <canvas ref={canvasRef} style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', zIndex: 2, padding: 24 }}>
        <h2>Custom Card</h2>
      </div>
    </div>
  );
}

API

GlassConfig

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | cornerRadius | number | 32 | Border radius, px | | borderWidth | number | 4 | Width of the refractive border zone, px | | refraction | number | 14 | Maximum refraction offset, px | | fresnelPower | number | 5 | Fresnel curve exponent (higher = sharper edge) | | highlight | number | 0.15 | Highlight intensity, 0–1 | | chromaticAberration | number | 0.035 | RGB split strength, 0–0.08 | | glassAlpha | number | 0.08 | Inner white overlay opacity | | innerBrighten | number | 1.08 | Inner area brightness multiplier | | blurAmount | number | 4 | CSS blur amount for the body, px | | shadow | string | glass shadow | CSS box-shadow | | background | string | rgba(…) | Background color behind the blur | | border | string | 1px solid … | CSS border |

useGlass(config?)

Low-level hook. Returns a RefObject<HTMLCanvasElement>.

  • Attach the returned ref to a <canvas> element positioned absolutely inside a container.
  • The container must have position: relative and explicit dimensions.
  • Apply your own CSS backdrop-filter: blur(...) to the container.

<Glass config? style? className? children>

Convenience wrapper component. Renders a <div> with:

  • CSS backdrop-filter: blur(config.blurAmount)
  • A WebGPU <canvas> overlay for the refractive edge
  • Inner <div> for children with borderRadius = cornerRadius - borderWidth for uniform border

How it works

┌─────────────────────────────────────────┐
│  CSS background (gradients, images)     │
│                                         │
│   ┌──────────────────────────────┐      │
│   │  Glass Panel                 │      │
│   │                              │      │
│   │  ┌── CSS blur zone ──-──┐    │      │
│   │  │  backdrop-filter     │    │      │
│   │  │  blur(4px)           │    │      │
│   │  │                      │    │      │
│   │  │   Content here       │    │      │
│   │  │                      │    │      │
│   │  └──────────────────────┘    │      │
│   │                              │      │
│   │  ┌── WebGPU edge ────-──┐    │      │
│   │  │  SDF refraction      │    │      │
│   │  │  Fresnel highlight   │    │      │
│   │  │  Chromatic aberration│    │      │
│   │  └──────────────────────┘    │      │
│   └──────────────────────────────┘      │
└─────────────────────────────────────────┘
  1. Background — A procedural texture is rendered to an invisible WebGPU texture (used for edge sampling).
  2. CSS Body — The card body uses backdrop-filter: blur() for a lightweight frosted glass look.
  3. WebGPU Edge — An alpha-blended canvas overlay renders the refractive border using SDF normals, Fresnel, and chromatic aberration.

Dev

git clone https://github.com/RuslanGabbasov/react-liquid-glass
cd react-glass
npm install
npm run dev

Open http://localhost:5173 in Chrome.

License

MIT