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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@specy/liquid-glass-react

v1.0.2

Published

React component for @specy/liquid-glass - A Three.js powered library to make apple's liquid with glass effect

Downloads

1,106

Readme

@specy/liquid-glass-react

React wrapper for @specy/liquid-glass - A Three.js powered glass effect component that recreates apple's liquid glass .

Installation

npm install @specy/liquid-glass-react

Basic Usage

Initialization is expensive, try to minimize re-renders and unnecessary unmouts.

The component does it's best to track the position of the target element in the page and update the effect, but it cannot track the top or left etc.. position changes, if you update them, you should call the forceUpdate method on the ref to re-render the effect, or use the renderKey prop to force a re-render when needed.

import React, { useMemo } from 'react';
import { LiquidGlass } from '@specy/liquid-glass-react';

function App() {
  // ⚠️ IMPORTANT: Memoize the glassStyle object to prevent unnecessary re-renders
  const glassStyle = useMemo(() => ({
    depth: 0.5,
    segments: 32,
    radius: 0.2,
    roughness: 0.1,
    transmission: 1,
    reflectivity: 0.5,
    ior: 1.5,
    dispersion: 0.1,
    thickness: 0.5
  }), []);

  return (
    <LiquidGlass
      glassStyle={glassStyle}
      wrapperStyle={{
        position: 'fixed',
        bottom: 0,
        left: 0,
        right: 0,
        width: 'fit-content',\
        margin: '0 auto',
      }}
      style={`padding: 1rem;`}
    >
      <div>
        <h1>Hello World!</h1>
        <p>This content is rendered inside the liquid glass effect.</p>
      </div>
    </LiquidGlass>
  );
}

Advanced Usage with Ref

import React, { useRef, useMemo, useCallback } from "react"
import { LiquidGlass, type LiquidGlassRef } from "@specy/liquid-glass-react"

function AdvancedExample() {
	const glassRef = useRef<LiquidGlassRef>(null)

	// ⚠️ IMPORTANT: Memoize all objects and callbacks
	const glassStyle = useMemo(
		() => ({
			depth: 0.8,
			segments: 64,
			radius: 0.3,
			transmission: 0.95,
			roughness: 0.05,
		}),
		[]
	)

	const onReady = useCallback((instance) => {
		console.log("LiquidGlass instance ready:", instance)
	}, [])

	const handleUpdateScreenshot = useCallback(async () => {
		await glassRef.current?.updateScreenshot()
	}, [])

	const handleUpdateStyle = useCallback(() => {
		glassRef.current?.updateGlassStyle({
			depth: Math.random(),
			transmission: 0.8 + Math.random() * 0.2,
		})
	}, [])

	return (
		<div>
			<LiquidGlass ref={glassRef} glassStyle={glassStyle} onReady={onReady}>
				<div style={{ padding: "30px" }}>
					<h2>Interactive Glass Effect</h2>
					<button onClick={handleUpdateScreenshot}>Update Screenshot</button>
					<button onClick={handleUpdateStyle}>Randomize Style</button>
				</div>
			</LiquidGlass>
		</div>
	)
}

Props

| Prop | Type | Default | Description | | --------------- | --------------------------------- | --------------- | ------------------------------------------------------------------- | | style | string | '' | Custom CSS styles to apply to the glass container | | wrapperStyle | React.CSSProperties | {} | React CSS properties to apply to the wrapper div | | glassStyle | GlassStyle | {} | Glass material properties (see GlassStyle interface) | | children | React.ReactNode | undefined | Content to render inside the glass container | | onReady | (instance: LiquidGlass) => void | undefined | Callback when the liquid glass instance is ready | | targetElement | HTMLElement | document.body | The target element to capture for the glass background effect | | renderKey | string | number | Unique key to force re-render the component when changed (manually) |

GlassStyle Interface

interface GlassStyle {
	depth?: number // Depth of the glass effect (0-1)
	segments?: number // Number of geometry segments for smoothness
	radius?: number // Border radius (0-1)
	tint?: number | null // Color tint (hex number or null)
	roughness?: number // Surface roughness (0-1)
	transmission?: number // Light transmission (0-1)
	reflectivity?: number // Surface reflectivity (0-1)
	ior?: number // Index of refraction
	dispersion?: number // Chromatic dispersion effect
	thickness?: number // Glass thickness
}

Ref Methods

The component exposes several methods through the ref:

interface LiquidGlassRef {
	getInstance(): LiquidGlass | null
	updateScreenshot(): Promise<void>
	forceUpdate(): Promise<void>
	updateGlassStyle(style: Partial<GlassStyle>): void
	getGlassStyle(): Required<GlassStyle> | null
	getElement(): HTMLElement | null
	getContent(): HTMLDivElement | null
  forcePositionUpdate(): void
  forceSizeUpdate(): void
}

Contributing

Issues and pull requests are welcome at the main repository.