Tirup Mehta
›Components›Liquid Ascii

Component

Liquid Ascii

Install guide

A real FLIP fluid simulation rendered as ASCII characters. Every drop is honest physics rendered in a grid of text, live on this page, then one install command in your project. Zero dependencies, MIT licensed.

Liquid ASCII fluid simulation. Enable JavaScript and move your cursor through it.

drag through the fluid

auto wave

Customize

Glyph face

Every number you set here flows straight into the install snippet below.

01

Install

npx shadcn@latest add https://tirup.in/components/r/liquid-ascii.json
import { LiquidAsciiDemo } from "@/components/liquid-ascii"

export function Hero() {
  return (
    <div className="h-[440px]">
      <LiquidAsciiDemo
        speed={1}
        cellSize={10}
        gravity={-25}
        fillHeight={0.5}
        cursorRadius={0.25}
        cursorForce={66}
        autoWave={true}
      />
    </div>
  )
}

The snippet follows your playground settings live. Read more in the install guide.

02

Props

PropTypeDefaultDescription
speednumber1Simulation timestep multiplier (0.1–3).
cellSizenumber10Character cell size in pixels (6–30). Drives sim + render together.
gravitynumber-25Gravity strength, negative = downward (−50–0).
fillHeightnumber0.5Fill fraction of the tank (0–1).
cursorRadiusnumber0.25Mouse influence as a fraction of the short side (0–0.5).
cursorForcenumber66Strength of the cursor push force (0–200).
autoWavebooleantrueGentle idle waves when untouched. Motion is input-driven otherwise.
classNamestring""Additional classes for the canvas element.
fontFamilystringsite monoCSS font-family for the glyphs. Any face your app loads or the system has, mono or not. Defaults to the host page's mono.
03

Fall

Every frame takes real delta time (clamped to 1/240–1/45s, scaled by speed) and runs two half-steps instead of one big jump. That's what keeps fast splashes stable. Gravity integrates first: velocity grows by (|gravity| / 25) × 1500 × dt each step.

04

Splat

Up to 20,000 particles (4 per cell) each cast two votes: horizontal velocity goes onto the vertical grid faces, vertical velocity onto the horizontal faces (a staggered MAC layout), normalized per face. Faces touching solid cells are wall faces, prescribed zero. They are the only zeros in the system. The result is snapshotted, and that snapshot is the memory the FLIP blend needs later.

05

Squeeze

Cells holding particles are marked fluid; the border is solid wall. Then 30 Jacobi iterations with 1.5 over-relaxation push the pressure field until every fluid cell agrees with its neighbours: divergence is read straight off the faces in a compact one-cell stencil, with the zeroed wall faces feeding the true no-penetration signal, and the gradient written back is its exact adjoint, so pressure can neither pump energy in nor leak volume out.

06

Return

Motion flows back to the particles as a 28/72 blend: a little of the smooth face velocity (stable, mushy) and a lot of the FLIP delta versus the snapshot (lively, detailed), sampled from interior faces only so the strict-zero wall faces steady the solve without ever damping a particle. Speeds clamp at 1150, particles advect, walls stop only the head-on component while sideways slide survives with light friction, with a 0.35-cell gap so liquid reaches the edges. Overfull cells get hash-jittered apart and up to 200 lost particles reseed per frame.

07

Touch

Your cursor is a spoon, not a magnet. Pointer velocity is smoothed and a 3×3 neighbourhood is checked first. Moving through empty air does nothing; only contact pushes, with strength falling off quadratically inside your cursor radius and at most one impulse per frame no matter how fast the pointer fires, so a gaming mouse, a touch screen and a laptop trackpad all push with the same energy. Vertical drags carry extra weight, because gravity is already fighting every upward push, so bottom-to-top strokes used to feel dead next to sideways slaps. Leave it alone for 2 seconds and a slow wandering column nudges the surface so the showcase stays breathing.

08

Ink

Each column's surface is the first row with real particle presence. Surface cells get the heaviest glyphs, fast spray above the surface gets mid-weight marks, and depth below fades through noise-weighted characters, with deliberately low cutoffs so hard stirring spreads the liquid instead of thinning it into nothing. Ink pulls from a pre-baked glyph atlas: every character at every quantized alpha held on one offscreen sheet, so a frame is a flat run of sprite blits with no font shaping and no string garbage. The theme rebuilds the sheet the instant your dark class flips. fontFamily swaps the face; past ~6,000 cells the renderer raises the cell size itself, so fullscreen costs what a card costs.

09

Metrics

particles

20,000 max

solver Passes

30 / frame

per Cell

4

dependencies

0

10

Honest limits

One tank, two dimensions, no obstacles, and cellSize is the whole performance budget (6–30px drives sim, particles, and glyphs; past ~6,000 cells the renderer raises it automatically so a fullscreen wall costs what a card costs). The loop sleeps when settled, pauses offscreen and in hidden tabs, draws one still frame for reduced-motion users, caps pixel ratio at 2, and debounces rebuilds at 120ms. Resizing or changing cell size holds exactly 4 particles per cell, adding or randomly thinning as needed, so the quantity of liquid never changes in any box, at any cell size.

11

Inspiration credit

The concept is inspired by React Bits' Liquid ASCII. My solver, renderer, and interaction code are written from scratch. Go compare them side by side.

12

Questions

What is Liquid Ascii?

Liquid Ascii is an open-source React component that renders a real-time FLIP fluid simulation as ASCII text on a canvas. Move your cursor through it and the liquid splashes in characters. It has zero dependencies and ships as a single file you own forever.

How do I install Liquid Ascii?

Run npx shadcn@latest add https://tirup.in/components/r/liquid-ascii.json in your Next.js or React project, then render the component inside any sized container. It adapts to light and dark mode automatically.

Can I use Liquid Ascii in commercial projects?

Yes. It is MIT licensed: copy it, modify it, ship it in commercial projects. No keys, no lock-in.

Does Liquid Ascii work on mobile?

It is desktop-first: the cursor interaction needs a precise pointer. Gate mounting behind a pointer or screen-size check and skip it on small screens. It respects prefers-reduced-motion with a still frame.

Can I change the glyph font?

Yes, any font you want. Pass fontFamily={"Inter"} and the component renders any CSS font face your app loads or the system has, monospace or not (proportional faces look great as fluid ink). Load the face in your own app however you like: next/font, a stylesheet link, or a system font. The component renders whatever family string it receives and falls back to your system mono if the face is missing. On this page the Customise panel bundles self-hosted faces so the picker renders identically for everyone.

How does the ASCII liquid effect actually work?

Up to 20,000 particles carry the fluid on a staggered MAC grid. Each frame runs gravity, a bilinear splat to grid faces, a 30-iteration pressure solve that keeps volume, and a PIC/FLIP blend back to particles. Density is binned per cell and rendered as glyphs: heavy characters on the surface, spray above it, depth-faded characters below.