# Lava lamp background

> Warm blobs rising, stretching and melting into each other across the whole screen, in pure HTML and CSS.

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

## Where to use it

Where the lava lamp loader is a small object, this background fills the whole screen with slow, melting shapes. It gives a psychedelic, retro glow to a music festival’s site, the page of an independent record label or the hero of a cocktail bar. The blobs rise from a pool at the bottom and merge on the way up.

It is a strong visual, so let it own a section, like the hero or the ticket banner, rather than sit behind long text. Lower the density for fewer, larger blobs. Warm oranges feel classic, while pink and electric blue feel more like a club night.

## Code

### HTML

```html
<div class="pt-lava"><svg width="0" height="0" style="position:absolute"><filter id="pt-lava-f"><feGaussianBlur in="SourceGraphic" stdDeviation="18"/><feColorMatrix values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 26 -11"/></filter></svg><b><i style="left:5.1%;--z:18.1cqmin;--t:17.9s;--dl:-8.7s"></i><i style="left:80.1%;--z:13.8cqmin;--t:13.7s;--dl:-17.8s"></i><i style="left:71.1%;--z:13.5cqmin;--t:21.0s;--dl:-17.0s"></i><i style="left:15.6%;--z:10.6cqmin;--t:20.5s;--dl:-14.7s"></i><i style="left:10.2%;--z:19.5cqmin;--t:20.9s;--dl:-21.2s"></i><i style="left:67.8%;--z:16.1cqmin;--t:22.0s;--dl:-21.1s"></i><i style="left:44.3%;--z:15.2cqmin;--t:13.1s;--dl:-13.1s"></i><i style="left:56.7%;--z:19.9cqmin;--t:13.3s;--dl:-1.8s"></i><i style="left:13.1%;--z:12.5cqmin;--t:21.3s;--dl:-21.2s"></i><i style="left:62.1%;--z:17.9cqmin;--t:14.5s;--dl:-3.6s"></i><u></u><u></u></b></div>
```

### CSS

```css
.pt-lava {
  --c1: #f97316;
  --c2: #f43f5e;
  --c3: #fbbf24;
  --k: 1;
  /* velocidad */
  --d: 1;
  /* densidad / escala */
  --o: 1;
  /* opacidad */
  --bg: #05060a;
  --fg: #ffffff;
  --blend: screen;
  min-height: 100vh;
}

.pt-lava {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-lava>* {
  opacity: var(--o);
}

.pt-lava {
  background: radial-gradient(ellipse at 50% 100%,color-mix(in srgb,var(--c2) 35%,var(--bg)),var(--bg) 75%)!important;
}

.pt-lava b {
  position: absolute;
  inset: 0;
  filter: url(#pt-lava-f);
}

.pt-lava i {
  position: absolute;
  bottom: -8%;
  width: calc(var(--z) * var(--d));
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(var(--c3),var(--c1));
  animation: pt-lava-u calc(var(--t) / var(--k)) ease-in-out infinite;
  animation-delay: var(--dl);
}

.pt-lava i:nth-child(even) {
  background: linear-gradient(var(--c1),var(--c2));
}

.pt-lava u {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 16%;
  bottom: -8%;
  border-radius: 50%;
  background: var(--c2);
}

.pt-lava u:last-child {
  top: -10%;
  bottom: auto;
  height: 12%;
  background: var(--c1);
}

@keyframes pt-lava-u {
  0%,100% {
    transform: translateY(0) scale(1,1);
  }
  50% {
    transform: translateY(-92cqh) scale(.8,1.25);
  }
}
```

### React

```tsx
// @ts-nocheck
import { useEffect, useRef } from "react";

const css = `
.pt-lava {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-lava>* {
  opacity: var(--o);
}

.pt-lava {
  background: radial-gradient(ellipse at 50% 100%,color-mix(in srgb,var(--c2) 35%,var(--bg)),var(--bg) 75%)!important;
}

.pt-lava b {
  position: absolute;
  inset: 0;
  filter: url(#pt-lava-f);
}

.pt-lava i {
  position: absolute;
  bottom: -8%;
  width: calc(var(--z) * var(--d));
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(var(--c3),var(--c1));
  animation: pt-lava-u calc(var(--t) / var(--k)) ease-in-out infinite;
  animation-delay: var(--dl);
}

.pt-lava i:nth-child(even) {
  background: linear-gradient(var(--c1),var(--c2));
}

.pt-lava u {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 16%;
  bottom: -8%;
  border-radius: 50%;
  background: var(--c2);
}

.pt-lava u:last-child {
  top: -10%;
  bottom: auto;
  height: 12%;
  background: var(--c1);
}

@keyframes pt-lava-u {
  0%,100% {
    transform: translateY(0) scale(1,1);
  }
  50% {
    transform: translateY(-92cqh) scale(.8,1.25);
  }
}

`;

export default function PatternLava() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-lava"
        style={{
          "--c1": "#f97316",
          "--c2": "#f43f5e",
          "--c3": "#fbbf24",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <svg width="0" height="0" style={{ position: "absolute" }}><filter id="pt-lava-f"><feGaussianBlur in="SourceGraphic" stdDeviation="18" /><feColorMatrix values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 26 -11" /></filter></svg><b><i style={{ left: "5.1%", "--z": "18.1cqmin", "--t": "17.9s", "--dl": "-8.7s" } as CSSProperties}></i><i style={{ left: "80.1%", "--z": "13.8cqmin", "--t": "13.7s", "--dl": "-17.8s" } as CSSProperties}></i><i style={{ left: "71.1%", "--z": "13.5cqmin", "--t": "21.0s", "--dl": "-17.0s" } as CSSProperties}></i><i style={{ left: "15.6%", "--z": "10.6cqmin", "--t": "20.5s", "--dl": "-14.7s" } as CSSProperties}></i><i style={{ left: "10.2%", "--z": "19.5cqmin", "--t": "20.9s", "--dl": "-21.2s" } as CSSProperties}></i><i style={{ left: "67.8%", "--z": "16.1cqmin", "--t": "22.0s", "--dl": "-21.1s" } as CSSProperties}></i><i style={{ left: "44.3%", "--z": "15.2cqmin", "--t": "13.1s", "--dl": "-13.1s" } as CSSProperties}></i><i style={{ left: "56.7%", "--z": "19.9cqmin", "--t": "13.3s", "--dl": "-1.8s" } as CSSProperties}></i><i style={{ left: "13.1%", "--z": "12.5cqmin", "--t": "21.3s", "--dl": "-21.2s" } as CSSProperties}></i><i style={{ left: "62.1%", "--z": "17.9cqmin", "--t": "14.5s", "--dl": "-3.6s" } as CSSProperties}></i><u></u><u></u></b>
      </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 background” block (Backgrounds) from AIMRAN Library to my project.

## What it is
Warm blobs rising, stretching and melting into each other across the whole screen, in pure HTML and CSS.

## Chosen settings
- Color 1: #f97316
- Color 2: #f43f5e
- Color 3: #fbbf24
- Speed: 1x (from 0.2 to 3x)
- Density / scale: 1x (from 0.5 to 2x)
- Opacity: 1 (from 0.2 to 1)

## 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
// @ts-nocheck
import { useEffect, useRef } from "react";

const css = `
.pt-lava {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-lava>* {
  opacity: var(--o);
}

.pt-lava {
  background: radial-gradient(ellipse at 50% 100%,color-mix(in srgb,var(--c2) 35%,var(--bg)),var(--bg) 75%)!important;
}

.pt-lava b {
  position: absolute;
  inset: 0;
  filter: url(#pt-lava-f);
}

.pt-lava i {
  position: absolute;
  bottom: -8%;
  width: calc(var(--z) * var(--d));
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(var(--c3),var(--c1));
  animation: pt-lava-u calc(var(--t) / var(--k)) ease-in-out infinite;
  animation-delay: var(--dl);
}

.pt-lava i:nth-child(even) {
  background: linear-gradient(var(--c1),var(--c2));
}

.pt-lava u {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 16%;
  bottom: -8%;
  border-radius: 50%;
  background: var(--c2);
}

.pt-lava u:last-child {
  top: -10%;
  bottom: auto;
  height: 12%;
  background: var(--c1);
}

@keyframes pt-lava-u {
  0%,100% {
    transform: translateY(0) scale(1,1);
  }
  50% {
    transform: translateY(-92cqh) scale(.8,1.25);
  }
}

`;

export default function PatternLava() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-lava"
        style={{
          "--c1": "#f97316",
          "--c2": "#f43f5e",
          "--c3": "#fbbf24",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <svg width="0" height="0" style={{ position: "absolute" }}><filter id="pt-lava-f"><feGaussianBlur in="SourceGraphic" stdDeviation="18" /><feColorMatrix values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 26 -11" /></filter></svg><b><i style={{ left: "5.1%", "--z": "18.1cqmin", "--t": "17.9s", "--dl": "-8.7s" } as CSSProperties}></i><i style={{ left: "80.1%", "--z": "13.8cqmin", "--t": "13.7s", "--dl": "-17.8s" } as CSSProperties}></i><i style={{ left: "71.1%", "--z": "13.5cqmin", "--t": "21.0s", "--dl": "-17.0s" } as CSSProperties}></i><i style={{ left: "15.6%", "--z": "10.6cqmin", "--t": "20.5s", "--dl": "-14.7s" } as CSSProperties}></i><i style={{ left: "10.2%", "--z": "19.5cqmin", "--t": "20.9s", "--dl": "-21.2s" } as CSSProperties}></i><i style={{ left: "67.8%", "--z": "16.1cqmin", "--t": "22.0s", "--dl": "-21.1s" } as CSSProperties}></i><i style={{ left: "44.3%", "--z": "15.2cqmin", "--t": "13.1s", "--dl": "-13.1s" } as CSSProperties}></i><i style={{ left: "56.7%", "--z": "19.9cqmin", "--t": "13.3s", "--dl": "-1.8s" } as CSSProperties}></i><i style={{ left: "13.1%", "--z": "12.5cqmin", "--t": "21.3s", "--dl": "-21.2s" } as CSSProperties}></i><i style={{ left: "62.1%", "--z": "17.9cqmin", "--t": "14.5s", "--dl": "-3.6s" } as CSSProperties}></i><u></u><u></u></b>
      </div>
    </>
  );
}
```

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