# Lava lamp loader

> A tall capsule where warm blobs drift up, sink back and merge, just like a little lava lamp.

- Category: [Loaders](https://library.aimran.es/components/loaders)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/css-lava
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A lava lamp is pure seventies nostalgia, so this loader brings instant character to a vintage clothing shop, a record store’s website or the menu page of a cocktail bar. The blobs rise and fall at their own pace and melt into each other and into the pool at the bottom, which makes it pleasant to watch during longer waits.

Orange and pink are the classic pairing, but deep purple and teal give it a moodier, late-night look. The shape is tall, so it fits a splash screen or a sidebar better than a row of buttons. There is also a full-screen lava background in this library.

## Code

### HTML

```html
<svg width="0" height="0" style="position:absolute"><filter id="ul-lava"><feGaussianBlur stdDeviation="5"/><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8"/></filter></svg><div class="ul-lava"><div><i style="--i:0"></i><i style="--i:1"></i><i style="--i:2"></i><i style="--i:3"></i></div></div>
```

### CSS

```css
.ul-lava {
  --c1: #0071e3;
  --c2: #8ec5ff;
  --s: 72px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --bg: #f5f5f7;
}

.ul-lava {
  width: var(--s);
  height: calc(var(--s) * 2);
  border-radius: calc(var(--s) / 2);
  border: 2px solid color-mix(in srgb,var(--c1) 35%,transparent);
  overflow: hidden;
}

.ul-lava>div {
  position: relative;
  width: 100%;
  height: 100%;
  filter: url(#ul-lava);
}

.ul-lava>div::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 18%;
  background: var(--c1);
}

.ul-lava i {
  position: absolute;
  left: calc(20% + var(--i) * 8%);
  bottom: 0;
  width: calc(var(--s) * (.32 + var(--i) * .05));
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c1);
  animation: ul-lava calc((3s + var(--i) * .8s) / var(--k)) ease-in-out infinite;
  animation-delay: calc(var(--i) * -1.1s / var(--k));
}

.ul-lava i:nth-child(2n) {
  background: var(--c2);
}

@keyframes ul-lava {
  0%,100% {
    transform: translateY(20%);
  }
  50% {
    transform: translateY(calc(var(--s) * -1.55));
  }
}
```

### React

```tsx
import type { CSSProperties } from "react";

const css = `
.ul-lava {
  width: var(--s);
  height: calc(var(--s) * 2);
  border-radius: calc(var(--s) / 2);
  border: 2px solid color-mix(in srgb,var(--c1) 35%,transparent);
  overflow: hidden;
}

.ul-lava>div {
  position: relative;
  width: 100%;
  height: 100%;
  filter: url(#ul-lava);
}

.ul-lava>div::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 18%;
  background: var(--c1);
}

.ul-lava i {
  position: absolute;
  left: calc(20% + var(--i) * 8%);
  bottom: 0;
  width: calc(var(--s) * (.32 + var(--i) * .05));
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c1);
  animation: ul-lava calc((3s + var(--i) * .8s) / var(--k)) ease-in-out infinite;
  animation-delay: calc(var(--i) * -1.1s / var(--k));
}

.ul-lava i:nth-child(2n) {
  background: var(--c2);
}

@keyframes ul-lava {
  0%,100% {
    transform: translateY(20%);
  }
  50% {
    transform: translateY(calc(var(--s) * -1.55));
  }
}
`;

export default function LoaderLava() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "72px",
          "--k": "1",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <svg width="0" height="0" style={{ position: "absolute" }}><filter id="ul-lava"><feGaussianBlur stdDeviation="5" /><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8" /></filter></svg><div className="ul-lava"><div><i style={{ "--i": "0" } as CSSProperties}></i><i style={{ "--i": "1" } as CSSProperties}></i><i style={{ "--i": "2" } as CSSProperties}></i><i style={{ "--i": "3" } as CSSProperties}></i></div></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Lava lamp loader” block (Loaders) from AIMRAN Library to my project.

## What it is
A tall capsule where warm blobs drift up, sink back and merge, just like a little lava lamp.

## Chosen settings
- Main color: #0071e3
- Secondary color: #8ec5ff
- Size: 72px (from 24 to 120px)
- Speed: 1x (from 0.5 to 2x)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
import type { CSSProperties } from "react";

const css = `
.ul-lava {
  width: var(--s);
  height: calc(var(--s) * 2);
  border-radius: calc(var(--s) / 2);
  border: 2px solid color-mix(in srgb,var(--c1) 35%,transparent);
  overflow: hidden;
}

.ul-lava>div {
  position: relative;
  width: 100%;
  height: 100%;
  filter: url(#ul-lava);
}

.ul-lava>div::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 18%;
  background: var(--c1);
}

.ul-lava i {
  position: absolute;
  left: calc(20% + var(--i) * 8%);
  bottom: 0;
  width: calc(var(--s) * (.32 + var(--i) * .05));
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--c1);
  animation: ul-lava calc((3s + var(--i) * .8s) / var(--k)) ease-in-out infinite;
  animation-delay: calc(var(--i) * -1.1s / var(--k));
}

.ul-lava i:nth-child(2n) {
  background: var(--c2);
}

@keyframes ul-lava {
  0%,100% {
    transform: translateY(20%);
  }
  50% {
    transform: translateY(calc(var(--s) * -1.55));
  }
}
`;

export default function LoaderLava() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "72px",
          "--k": "1",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <svg width="0" height="0" style={{ position: "absolute" }}><filter id="ul-lava"><feGaussianBlur stdDeviation="5" /><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8" /></filter></svg><div className="ul-lava"><div><i style={{ "--i": "0" } as CSSProperties}></i><i style={{ "--i": "1" } as CSSProperties}></i><i style={{ "--i": "2" } as CSSProperties}></i><i style={{ "--i": "3" } as CSSProperties}></i></div></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
