# Metaballs

> Drift soft blobs that merge and separate like liquid, with an optional ball that follows the pointer.

Source: https://www.honestui.com/docs/shaders/metaballs

<ComponentPreview name="metaballs-demo" />

## Overview [#overview]

Metaballs draws a handful of round blobs that wander slowly and melt into one another when they meet, then pull apart again. Each ball takes a color from `colors` in turn, and where two merge their colors blend over a short distance instead of averaging into mud. With `followPointer`, one more ball tracks the pointer and merges with the rest, which makes an empty state, a sign-in panel, or a loading screen feel responsive without demanding attention.

Use a small `count` and low `spread` for a compact cluster behind a logo, or more balls across the full container for a background. Set `softness` above 0 for a blurred glow instead of crisp edges, and `backgroundColor="transparent"` to place the blobs over your own surface.

## Installation [#installation]

<CommandBlock commands="[&#x22;honestui&#x22;]" />

## Usage [#usage]

```tsx
import { Metaballs } from "honestui/shaders"

<div className="h-80 bg-neutral-950">
  <Metaballs
    className="size-full"
    colors={["#6366f1", "#ec4899"]}
    count={8}
  />
</div>
```

## Accessibility [#accessibility]

Metaballs is decorative: the canvas is hidden from assistive technology, and text or actions belong in normal HTML above it. The pointer ball is an enhancement only, so nothing should depend on it, and it does nothing for keyboard or touch users. Animation pauses while the effect is offscreen, while the document is hidden, and when the user prefers reduced motion; a still frame is rendered, and the pointer ball still follows the pointer without easing. Use `paused` for your own control, and give the container a background for when WebGL is unavailable.

## API Reference [#api-reference]


  ### `count`

type: `number` · default: `9`

Number of drifting balls, from 1 to 20.

  ### `colors`

type: `string[]` · default: `[&#x22;#6366f1&#x22;, &#x22;#a855f7&#x22;, &#x22;#ec4899&#x22;, &#x22;#38bdf8&#x22;]`

Ball colors, up to 8. Balls take them in turn; the pointer ball uses the first.

  ### `size`

type: `number` · default: `1`

Overall ball size.

  ### `spread`

type: `number` · default: `0.8`

How far the balls wander, from 0 (clustered in the center) to 1 (the full container).

  ### `softness`

type: `number` · default: `0`

Softness of the edges, from 0 (crisp) to 1 (a soft glow).

  ### `speed`

type: `number` · default: `1`

Animation speed. Changing it never makes the balls jump.

  ### `followPointer`

type: `boolean` · default: `true`

Adds a ball that follows the pointer and merges with the others.

  ### `backgroundColor`

type: `string` · default: `&#x22;transparent&#x22;`

Background color, or 

    `"transparent"`

     to let the container show through.

  ### `seed`

type: `number` · default: `1`

Changes the ball paths while keeping the same look.

  ### `paused`

type: `boolean` · default: `false`

Renders a static frame instead of animating.

  ### `className`

type: `string`

Class for sizing and positioning the container.
