Gooey

Pieces that merge like goo and move like liquid, while your content stays crisp.

Click the plus
Drag the thumb
Drag me around 45 files
Drag the pill

Playground

Click the plus.

<script>
  import { Liquid } from 'runeglow/liquid-gooey';

  let open = $state(false);
</script>

<Liquid fill="#202020" shadow="0 2px 6px rgb(0 0 0 / 0.05), 0 4px 42px rgb(0 0 0 / 0.24)">
  <Liquid.Item x={open ? -54 : 0} y={open ? -34 : 0} transition={{ duration: 550, ease: 'cubic-bezier(0.34, 1.56, 0.64, 1)' }}>
    <button class="round">…</button>
  </Liquid.Item>
  <Liquid.Item y={open ? -64 : 0} transition={{ duration: 550, ease: 'cubic-bezier(0.34, 1.56, 0.64, 1)' }} delay={40}>
    <button class="round">…</button>
  </Liquid.Item>
  <Liquid.Item x={open ? 54 : 0} y={open ? -34 : 0} transition={{ duration: 550, ease: 'cubic-bezier(0.34, 1.56, 0.64, 1)' }} delay={80}>
    <button class="round">…</button>
  </Liquid.Item>
  <Liquid.Item>
    <button class="round" onclick={() => (open = !open)}>+</button>
  </Liquid.Item>
</Liquid>

Install

pnpm add runeglow

Or copy just this library’s source into your project, with the shadcn-svelte CLI:

npx shadcn-svelte@latest add https://runeglow.dev/r/liquid-gooey.json
import { Liquid } from 'runeglow/liquid-gooey';

Usage

A Liquid group draws one merged surface behind its children. Wrap each piece in Liquid.Item and it joins that surface.

<script>
  import { Liquid } from 'runeglow/liquid-gooey';
</script>

<Liquid fill="#202020">
  <Liquid.Item><button class="round">A</button></Liquid.Item>
  <Liquid.Item><button class="round">B</button></Liquid.Item>
</Liquid>

<style>
  /* The liquid is the surface: keep your own elements transparent. */
  .round { background: transparent; border: 0; border-radius: 50%; }
</style>

Give an item a position and the library animates the element and its liquid together.

<script>
  import { Liquid } from 'runeglow/liquid-gooey';

  let open = $state(false);
</script>

<Liquid fill="#202020">
  <!-- The library moves the element and its liquid together. -->
  <Liquid.Item y={open ? -64 : 0} transition="bouncy">
    <button class="round">…</button>
  </Liquid.Item>
  <Liquid.Item>
    <button class="round" onclick={() => (open = !open)}>+</button>
  </Liquid.Item>
</Liquid>

For anything you move yourself, such as a drag or a Svelte spring, pick an effect and the liquid follows the element’s real position.

<!-- Or move the element yourself; the liquid follows what it measures. -->
<Liquid fill="#525252">
  <Liquid.Item effect="move" move={{ stretch: 0.6, trail: 0.35 }}>
    <div class="thumb" style:transform="translateX({x}px)"></div>
  </Liquid.Item>
</Liquid>
// Liquid.Item is also exported on its own.
import { Liquid, LiquidItem } from 'runeglow/liquid-gooey';

Liquid props

Prop Type Default Description
blur number 6 Goo blur in px: how far apart pieces start bridging.
contrast number 18 How sharp the liquid edge is.
fill string '#fff' Colour of the liquid surface. Any CSS colour, var() included.
shadow string – box-shadow syntax, drawn on the merged surface. inset layers paint inside the liquid edge.
waviness number 0 Max px the liquid edge undulates. 0 keeps it calm.
wavinessFreq number 0.018 Noise frequency of the undulation. Lower is longer, lazier waves.
filterPadding number 24 Extra room in px for pieces that travel outside the group box.
filter string – Raw SVG filter primitives that replace the goo chain.
ref HTMLDivElement | null – The group element. Bindable with bind:ref.
...rest HTMLAttributes<HTMLDivElement> – class, style and other attributes go to the group element.

Liquid.Item props

Prop Type Default Description
effect 'morph' | 'move' | 'bend' | 'melt' 'morph' morph merges pieces; move trails a moving element; bend bows the body with velocity; melt runs two images into each other.
x, y, scale number – Position set by the library, which animates the element and its liquid in step.
transition 'snappy' | 'smooth' | 'bouncy' | SpringConfig | { duration, ease } 'smooth' How x, y and scale animate.
delay number 0 Transition delay in ms, for staggering.
observe boolean – You animate the element; the liquid follows its rendered box. Implied by morph.shape, dissolve, move and bend.
morph MorphTuning – { shape, speed, bounce, contentBlur, advanced }. shape makes the surface spring behind size changes.
dissolve boolean | number | DissolveOptions – Melts this item’s picture into a touching neighbour. true, a 0 to 1 strength, or full options.
move MoveTuning – { springiness, wobble, stretch, trail }, each 0 to 1.
bend BendTuning – { vertical, horizontal }, each 0 to 1.
melt ImageMeltOptions & { src? } – { blur, contrast, reach, fade, warp, mix, mixBlur, gravity, waviness }. The image is found from an <img> inside, or given as src.
radius number | [tl, tr, br, bl] measured Overrides the border radius read from the element.
class, style string – Applied to the item’s wrapper.

Notes

  • The liquid is drawn behind your elements, so they should be transparent. Their shape comes from the group’s fill and shadow.
  • Text and icons are never run through the goo filter, so they stay sharp while the surface merges.
  • effect="melt" works on the first two melt items in a group, and each needs an image.
  • effect="bend" publishes the live bend as --lg-bend-x, --lg-bend-y (px) and --lg-bend-xn, --lg-bend-yn (unitless) on the item, so content can lean with the surface.
  • It runs on SVG filters and works in Chrome, Firefox and Safari.