# 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-vue` (Vue 3.5+ + 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/vue/src/components/fluid-cursor

## Import

```vue
<script setup lang="ts">
import { FluidCursor } from 'fancy-ui-vue';
</script>
```

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

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

Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in a Vue template; when one differs from the Svelte name, the Svelte name follows in parentheses. Snippets become named slots (`#default` is the default snippet), a prop the Vue port declares as a model is a `v-model:<name>` (except `ref`, exposed via `defineExpose({ ref })`: put a template ref on the component and read `.ref`) and callbacks are listeners (`onclick` is `@click`). Every component sets `inheritAttrs: false`: `class` is a declared prop, merged where the Svelte component applies it (not always the root element), and only when the props table below lists it; other attributes do not fall through unless the package README lists the component as forwarding native attributes. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/vue#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

```vue
<script setup lang="ts">
import { FluidCursor } from "fancy-ui-vue";
</script>

<template>
	<div class="relative h-64 w-full overflow-hidden rounded-lg border">
		<FluidCursor />
		<div class="pointer-events-none absolute inset-0 flex items-center justify-center">
			<p class="text-sm select-none">Move your cursor here</p>
		</div>
	</div>
</template>
```
