# FluidCursor

> Full Navier-Stokes fluid simulation that swirls color in response to cursor and touch movement, running on WebGL2 with a WebGL1 fallback and an optional WebGPU HDR path for wide-gamut, brighter-than-white glow.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: Effects
- Tags: cursor, webgl, fluid, simulation, interactive
- Types: `FluidCursorProps`, `FluidCursorAdvancedProps`, `FluidCursorHandle`, `FluidRenderLevel`
- Docs: https://fancy-ui.rama.app/docs/components/fluid-cursor
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/fluid-cursor

## Import

```tsx
import { FluidCursor } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `simResolution` | `number` | `128` | Simulation grid resolution |
| `dyeResolution` | `number` | `1440` | Dye/color buffer resolution |
| `captureResolution` | `number` | `512` | Capture buffer resolution |
| `densityDissipation` | `number` | `3.5` | Rate at which density fades |
| `velocityDissipation` | `number` | `2` | Rate at which velocity fades |
| `pressure` | `number` | `0.1` | Pressure solver strength |
| `pressureIterations` | `number` | `20` | Number of pressure solver iterations |
| `curl` | `number` | `3` | Amount of curl/vorticity |
| `splatRadius` | `number` | `0.2` | Radius of fluid splats |
| `splatForce` | `number` | `6000` | Force of fluid splats |
| `shading` | `boolean` | `true` | Enable fluid shading |
| `colorUpdateSpeed` | `number` | `10` | Speed of color changes |
| `backColor` | `ColorRGB \| string` | `{ r: 0.5, g: 0, b: 0 }` | Background color |
| `transparent` | `boolean` | `true` | Transparent background |
| `fluidColor` | `string` | — | Override all fluid with a single color |
| `fluidColors` | `string[]` | — | Array of colors to cycle through for fluid splats |
| `colorIntensity` | `number` | `0.15` | Intensity of color mixing |
| `autoSplat` | `boolean` | `false` | Automatically create random splats |
| `autoSplatInterval` | `number` | `1500` | Interval between auto-splats in ms |
| `interactive` | `boolean` | `true` | React to mouse/touch input |
| `pauseWhenHidden` | `boolean` | `true` | Pause simulation when tab is hidden |
| `splatOnMount` | `boolean` | `false` | Create a splat on mount |
| `allowMultiple` | `boolean` | `false` | Allow multiple instances simultaneously |
| `contained` | `boolean` | `true` | Confine simulation to parent container |
| `hdr` | `boolean` | `false` | Render via the WebGPU HDR engine — wide gamut + brighter-than-white glow on HDR displays. Needs Chrome/Edge 129+ or Safari 26+; falls back to wide-gamut WebGL (Chrome 104+, Safari 16.4+, Firefox 132+), then to standard rendering |
| `hdrBoost` | `number` | `1.5` | Display exposure multiplier in HDR mode, clamped to [1, 4] |
| `dither` | `boolean` | `false` | Experimental retro bitmap dithering — pixelates the fluid to a chunky grid and quantizes color with an ordered 4x4 Bayer threshold. Forces the WebGL renderer; hdr is ignored while set |
| `ditherPixelSize` | `number` | `3` | Size of one dithered pixel in CSS pixels, minimum 1 |
| `ditherLevels` | `number` | `4` | Color levels per channel in dither mode, clamped to [2, 16] |

## Example

```tsx
import { FluidCursor } from "fancy-ui-react";

export function FluidCursorExample() {
	return (
		<div className="relative h-64 w-full overflow-hidden rounded-lg border">
			<FluidCursor />
			<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
				<p className="text-sm select-none">Move your cursor here</p>
			</div>
		</div>
	);
}
```
