Read page as text

NIB / PLAYGROUND

Liquid glass playground — NibComponents

Try liquid glass in Flutter. Explore clear and depth water, merging drops and shared bubbles over a live Flutter subtree.

Open interactive view

Explore clear and depth water, merging drops and shared bubbles over a live Flutter subtree.

Read the full component guide and API

Public widgets and APIs

  • NibWaterGlass
  • NibWaterSurface
  • NibWaterController
  • NibWaterConfig
  • NibWaterDrop
  • NibWaterImpulse
  • NibWaterInteraction
  • NibWaterPhase
  • NibWaterRenderPath
  • NibWaterRenderStatus
  • NibWaterSampling
  • NibWaterQuality
  • NibWaterMaterial
  • NibBubbleEmitter
  • NibLiquidGlass
  • glassLightFromPointer
  • NibGlass

Example Dart code

import 'package:flutter/material.dart';
import 'package:nib_components/nib_components.dart';
import 'package:nib_motion/nib_motion.dart';

void main() => runApp(const MaterialApp(home: WaterExample()));

class WaterExample extends StatefulWidget {
  const WaterExample({super.key});
  @override
  State<WaterExample> createState() => _WaterExampleState();
}

class _WaterExampleState extends State<WaterExample> {
  final water = NibWaterController(drops: const [
    NibWaterDrop(id: 1, center: Offset(90, 130), radius: 48),
    NibWaterDrop(id: 2, center: Offset(270, 130), radius: 48),
  ]);

  @override
  void dispose() {
    water.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => Scaffold(
    body: SafeArea(child: Center(child: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        SizedBox(width: 360, height: 260, child: NibWaterGlass(
          controller: water,
          surface: true,
          animated: true,
        sampling: NibWaterSampling.live,
          background: const ColoredBox(
            color: Color(0xFFECEBE5),
            child: GridPaper(
              color: Color(0xFF969B96), interval: 20,
              divisions: 1, subdivisions: 1,
              child: Center(child: Text('Look through the water',
                style: TextStyle(color: Color(0xFF202724)))),
            ),
          ),
        )),
        TextButton(
          onPressed: () => water.disturb(const Offset(180, 130)),
          child: const Text('Make a wave'),
        ),
      ],
    ))),
  );
}

Playground controls

ControlTypeOptions or rangeHelp
Materialchoicewater, legacyWater Lab is the new review target. Legacy keeps the existing glass available.
Scenechoicedroplets, surface, component, bubblesAll scenes use NibWaterSurface. Bubbles uses one bounded emitter and one shared sample.
Pointer modechoicedrag, disturbDrag moves a drop. Disturb adds waves and a movement wake.
Backgroundchoicegrid, typography, image, scrollingNeutral grid and text reveal refraction. Image is original local vector art; scrolling has a Move background button.
Disturbance strength · pxnumber0.0–12.0Artistic height amplitude, not physical pressure.
Wave speed · px/snumber40.0–400.0How quickly a disturbance propagates in receiver-local pixels.
Damping · /snumber0.3–8.0Higher damping removes waves sooner.
Optical strengthnumber0.0–40.0Artistic background displacement. Zero removes refraction; this is not a physical refractive index.
Surface highlightnumber0.0–1.0Light intensity follows the evolving surface normal.
Wavelength · pxnumber16.0–120.0Distance between wave crests in local logical pixels.
Shape recovery · /snumber2.0–30.0Controls how quickly the drop arrangement approaches merge or split targets.
Sampling policychoicelive, static, throttled, legacyLive samples child layers during composition. Static requires explicit invalidation; throttled permits older input. Legacy preserves the old asynchronous path.
Water opticschoiceclear, depthClear adds no deliberate blur. Depth adds bounded artistic absorption; it is not volumetric fluid simulation.
Quality · multiple of DPRnumber0.25–2.0Device-relative requested scale; bounded to four million pixels, 16 MB input and 4096 pixels per axis. Effective size is shown in Development details.
Intentional blur · logical pxnumber0.0–8.0Opt-in source blur, independent of resolution and wave speed. Zero preserves clear content.
Legacy sampling · pixels/logical pxnumber0.5–2.0Only the legacy sampling policy uses this absolute scale; its two-million-pixel cap is unchanged.
Backdropchoicegrid, contentChanges the local scene behind the glass; the website stays dark.
Shapechoicerounded, capsuleBoth shapes use the real borderRadius property.
Note texttextForeground content stays independent of the glass filter.
Animated presstoggleEnabled in this demo. Uses NibMotion and a 0.98 press scale.
Pointer responsetoggleControls decorative light tracking and press response, not the child button.
Backdrop blurnumber0.0–20.0Gaussian blur on both renderer paths.
Rim highlightnumber0.0–1.0Lighting intensity. The extra border is controlled separately.
Extra bordertoggleAdds the component outline; the engine rim can remain visible when this is off.
Dome thicknessnumber1.0–48.0Shader path only; logical pixels. This does not change layout size.
Refraction indexnumber1.0–1.8Shader path only. 1.0 requests no bending.
Color dispersionnumber0.0–0.15Shader path only. Zero disables the extra red/blue sampling.
Backdrop saturationnumber0.0–2.0Shader path only. 1.0 leaves backdrop saturation unchanged.

Water Lab uses the stable public water API. The refractive path must be checked in a real browser; fallback rendering does not satisfy visual review.

The model preserves source-region area as a 2D mass proxy. It does not conserve exact silhouette area or solve 3D fluid flow.

Capture is restricted to the designated bounded background. Platform views and content outside that subtree are not supported background inputs.

Android GPU, physical touch and screen-reader validation remain separate checks after maintainer web review.