# Falling petals

> Petals tumble down in 3D and sway from side to side, as if a light breeze were carrying them.

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

## Where to use it

Falling petals are a gentle, romantic touch for a wedding website, the spring collection of a flower shop, a Japanese restaurant during cherry blossom season or a beauty brand’s landing page. Each petal has its own size, speed and swing, so the fall looks natural. A falling petals background in HTML and CSS, with no images.

Pink on deep indigo is the default, but white petals on soft green read as spring and gold on navy feels festive. Behind forms and product photos, shrink the petals or lower the opacity so nothing seems to land on the buy button.

## Code

### HTML

```html
<div class="pt-petals"><i style="left:0.0%;--t:17.9s;--dl:-4.9s;--sz:12.2px;--sw:42.1px"></i><i style="left:63.4%;--t:10.7s;--dl:-17.4s;--sz:20.7px;--sw:26.3px"></i><i style="left:87.4%;--t:18.5s;--dl:-11.2s;--sz:16.3px;--sw:37.6px"></i><i style="left:30.7%;--t:15.3s;--dl:-6.8s;--sz:20.4px;--sw:67.1px"></i><i style="left:36.9%;--t:12.2s;--dl:-18.3s;--sz:21.3px;--sw:31.6px"></i><i style="left:18.5%;--t:10.5s;--dl:-15.4s;--sz:13.6px;--sw:62.6px"></i><i style="left:5.4%;--t:15.4s;--dl:-11.0s;--sz:11.1px;--sw:39.4px"></i><i style="left:44.2%;--t:18.4s;--dl:-5.6s;--sz:17.3px;--sw:23.7px"></i><i style="left:87.0%;--t:12.3s;--dl:-15.9s;--sz:11.8px;--sw:53.3px"></i><i style="left:19.8%;--t:17.9s;--dl:-18.5s;--sz:22.0px;--sw:30.1px"></i><i style="left:72.6%;--t:10.2s;--dl:-9.2s;--sz:11.2px;--sw:60.4px"></i><i style="left:32.6%;--t:14.1s;--dl:-9.9s;--sz:10.1px;--sw:53.2px"></i><i style="left:80.5%;--t:12.0s;--dl:-14.3s;--sz:10.4px;--sw:40.6px"></i><i style="left:73.5%;--t:17.1s;--dl:-19.8s;--sz:18.4px;--sw:32.2px"></i><i style="left:3.1%;--t:19.0s;--dl:-3.8s;--sz:12.5px;--sw:35.4px"></i><i style="left:43.6%;--t:14.0s;--dl:-4.1s;--sz:16.1px;--sw:64.5px"></i><i style="left:42.4%;--t:15.2s;--dl:-14.0s;--sz:13.5px;--sw:30.1px"></i><i style="left:70.0%;--t:13.9s;--dl:-18.4s;--sz:21.7px;--sw:24.9px"></i><i style="left:26.1%;--t:14.8s;--dl:-8.9s;--sz:17.0px;--sw:20.4px"></i><i style="left:22.3%;--t:11.3s;--dl:-0.5s;--sz:20.2px;--sw:33.9px"></i><i style="left:64.1%;--t:15.9s;--dl:-12.7s;--sz:20.2px;--sw:58.2px"></i><i style="left:15.3%;--t:13.1s;--dl:-9.1s;--sz:16.2px;--sw:66.7px"></i><i style="left:3.6%;--t:19.2s;--dl:-8.0s;--sz:12.3px;--sw:44.7px"></i><i style="left:5.0%;--t:10.3s;--dl:-7.2s;--sz:15.4px;--sw:56.9px"></i><i style="left:0.4%;--t:10.8s;--dl:-2.6s;--sz:12.7px;--sw:29.1px"></i><i style="left:23.2%;--t:12.7s;--dl:-11.1s;--sz:21.5px;--sw:68.6px"></i></div>
```

### CSS

```css
.pt-petals {
  --c1: #fbcfe8;
  --c2: #f472b6;
  --c3: #312e81;
  --k: 1;
  /* velocidad */
  --d: 1;
  /* densidad / escala */
  --o: 1;
  /* opacidad */
  --bg: #05060a;
  --fg: #ffffff;
  --blend: screen;
  min-height: 100vh;
}

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

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

.pt-petals {
  background: radial-gradient(ellipse at 50% 120%,color-mix(in srgb,var(--c3) 70%,var(--bg)),var(--bg) 70%)!important;
}

.pt-petals i {
  position: absolute;
  top: -8%;
  width: calc(var(--sz) * var(--d));
  aspect-ratio: 1;
  border-radius: 150% 0 150% 0;
  background: linear-gradient(135deg,var(--c1),var(--c2));
  box-shadow: 0 0 12px color-mix(in srgb,var(--c2) 40%,transparent);
  animation: pt-petals-f calc(var(--t) / var(--k)) linear infinite,pt-petals-s calc(var(--t) / 4 / var(--k)) ease-in-out infinite alternate;
  animation-delay: var(--dl);
}

.pt-petals i:nth-child(odd) {
  border-radius: 0 150% 0 150%;
}

@keyframes pt-petals-f {
  from {
    transform: translateY(0) rotate3d(1,1,0,0deg);
  }
  to {
    transform: translateY(120cqh) rotate3d(1,1,0,720deg);
  }
}

@keyframes pt-petals-s {
  from {
    translate: calc(var(--sw) * -1) 0;
  }
  to {
    translate: var(--sw) 0;
  }
}
```

### React

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

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

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

.pt-petals {
  background: radial-gradient(ellipse at 50% 120%,color-mix(in srgb,var(--c3) 70%,var(--bg)),var(--bg) 70%)!important;
}

.pt-petals i {
  position: absolute;
  top: -8%;
  width: calc(var(--sz) * var(--d));
  aspect-ratio: 1;
  border-radius: 150% 0 150% 0;
  background: linear-gradient(135deg,var(--c1),var(--c2));
  box-shadow: 0 0 12px color-mix(in srgb,var(--c2) 40%,transparent);
  animation: pt-petals-f calc(var(--t) / var(--k)) linear infinite,pt-petals-s calc(var(--t) / 4 / var(--k)) ease-in-out infinite alternate;
  animation-delay: var(--dl);
}

.pt-petals i:nth-child(odd) {
  border-radius: 0 150% 0 150%;
}

@keyframes pt-petals-f {
  from {
    transform: translateY(0) rotate3d(1,1,0,0deg);
  }
  to {
    transform: translateY(120cqh) rotate3d(1,1,0,720deg);
  }
}

@keyframes pt-petals-s {
  from {
    translate: calc(var(--sw) * -1) 0;
  }
  to {
    translate: var(--sw) 0;
  }
}

`;

export default function PatternPetals() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-petals"
        style={{
          "--c1": "#fbcfe8",
          "--c2": "#f472b6",
          "--c3": "#312e81",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <i style={{ left: "0.0%", "--t": "17.9s", "--dl": "-4.9s", "--sz": "12.2px", "--sw": "42.1px" } as CSSProperties}></i><i style={{ left: "63.4%", "--t": "10.7s", "--dl": "-17.4s", "--sz": "20.7px", "--sw": "26.3px" } as CSSProperties}></i><i style={{ left: "87.4%", "--t": "18.5s", "--dl": "-11.2s", "--sz": "16.3px", "--sw": "37.6px" } as CSSProperties}></i><i style={{ left: "30.7%", "--t": "15.3s", "--dl": "-6.8s", "--sz": "20.4px", "--sw": "67.1px" } as CSSProperties}></i><i style={{ left: "36.9%", "--t": "12.2s", "--dl": "-18.3s", "--sz": "21.3px", "--sw": "31.6px" } as CSSProperties}></i><i style={{ left: "18.5%", "--t": "10.5s", "--dl": "-15.4s", "--sz": "13.6px", "--sw": "62.6px" } as CSSProperties}></i><i style={{ left: "5.4%", "--t": "15.4s", "--dl": "-11.0s", "--sz": "11.1px", "--sw": "39.4px" } as CSSProperties}></i><i style={{ left: "44.2%", "--t": "18.4s", "--dl": "-5.6s", "--sz": "17.3px", "--sw": "23.7px" } as CSSProperties}></i><i style={{ left: "87.0%", "--t": "12.3s", "--dl": "-15.9s", "--sz": "11.8px", "--sw": "53.3px" } as CSSProperties}></i><i style={{ left: "19.8%", "--t": "17.9s", "--dl": "-18.5s", "--sz": "22.0px", "--sw": "30.1px" } as CSSProperties}></i><i style={{ left: "72.6%", "--t": "10.2s", "--dl": "-9.2s", "--sz": "11.2px", "--sw": "60.4px" } as CSSProperties}></i><i style={{ left: "32.6%", "--t": "14.1s", "--dl": "-9.9s", "--sz": "10.1px", "--sw": "53.2px" } as CSSProperties}></i><i style={{ left: "80.5%", "--t": "12.0s", "--dl": "-14.3s", "--sz": "10.4px", "--sw": "40.6px" } as CSSProperties}></i><i style={{ left: "73.5%", "--t": "17.1s", "--dl": "-19.8s", "--sz": "18.4px", "--sw": "32.2px" } as CSSProperties}></i><i style={{ left: "3.1%", "--t": "19.0s", "--dl": "-3.8s", "--sz": "12.5px", "--sw": "35.4px" } as CSSProperties}></i><i style={{ left: "43.6%", "--t": "14.0s", "--dl": "-4.1s", "--sz": "16.1px", "--sw": "64.5px" } as CSSProperties}></i><i style={{ left: "42.4%", "--t": "15.2s", "--dl": "-14.0s", "--sz": "13.5px", "--sw": "30.1px" } as CSSProperties}></i><i style={{ left: "70.0%", "--t": "13.9s", "--dl": "-18.4s", "--sz": "21.7px", "--sw": "24.9px" } as CSSProperties}></i><i style={{ left: "26.1%", "--t": "14.8s", "--dl": "-8.9s", "--sz": "17.0px", "--sw": "20.4px" } as CSSProperties}></i><i style={{ left: "22.3%", "--t": "11.3s", "--dl": "-0.5s", "--sz": "20.2px", "--sw": "33.9px" } as CSSProperties}></i><i style={{ left: "64.1%", "--t": "15.9s", "--dl": "-12.7s", "--sz": "20.2px", "--sw": "58.2px" } as CSSProperties}></i><i style={{ left: "15.3%", "--t": "13.1s", "--dl": "-9.1s", "--sz": "16.2px", "--sw": "66.7px" } as CSSProperties}></i><i style={{ left: "3.6%", "--t": "19.2s", "--dl": "-8.0s", "--sz": "12.3px", "--sw": "44.7px" } as CSSProperties}></i><i style={{ left: "5.0%", "--t": "10.3s", "--dl": "-7.2s", "--sz": "15.4px", "--sw": "56.9px" } as CSSProperties}></i><i style={{ left: "0.4%", "--t": "10.8s", "--dl": "-2.6s", "--sz": "12.7px", "--sw": "29.1px" } as CSSProperties}></i><i style={{ left: "23.2%", "--t": "12.7s", "--dl": "-11.1s", "--sz": "21.5px", "--sw": "68.6px" } as CSSProperties}></i>
      </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 “Falling petals” block (Backgrounds) from AIMRAN Library to my project.

## What it is
Petals tumble down in 3D and sway from side to side, as if a light breeze were carrying them.

## Chosen settings
- Color 1: #fbcfe8
- Color 2: #f472b6
- Color 3: #312e81
- 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-petals {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

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

.pt-petals {
  background: radial-gradient(ellipse at 50% 120%,color-mix(in srgb,var(--c3) 70%,var(--bg)),var(--bg) 70%)!important;
}

.pt-petals i {
  position: absolute;
  top: -8%;
  width: calc(var(--sz) * var(--d));
  aspect-ratio: 1;
  border-radius: 150% 0 150% 0;
  background: linear-gradient(135deg,var(--c1),var(--c2));
  box-shadow: 0 0 12px color-mix(in srgb,var(--c2) 40%,transparent);
  animation: pt-petals-f calc(var(--t) / var(--k)) linear infinite,pt-petals-s calc(var(--t) / 4 / var(--k)) ease-in-out infinite alternate;
  animation-delay: var(--dl);
}

.pt-petals i:nth-child(odd) {
  border-radius: 0 150% 0 150%;
}

@keyframes pt-petals-f {
  from {
    transform: translateY(0) rotate3d(1,1,0,0deg);
  }
  to {
    transform: translateY(120cqh) rotate3d(1,1,0,720deg);
  }
}

@keyframes pt-petals-s {
  from {
    translate: calc(var(--sw) * -1) 0;
  }
  to {
    translate: var(--sw) 0;
  }
}

`;

export default function PatternPetals() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-petals"
        style={{
          "--c1": "#fbcfe8",
          "--c2": "#f472b6",
          "--c3": "#312e81",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <i style={{ left: "0.0%", "--t": "17.9s", "--dl": "-4.9s", "--sz": "12.2px", "--sw": "42.1px" } as CSSProperties}></i><i style={{ left: "63.4%", "--t": "10.7s", "--dl": "-17.4s", "--sz": "20.7px", "--sw": "26.3px" } as CSSProperties}></i><i style={{ left: "87.4%", "--t": "18.5s", "--dl": "-11.2s", "--sz": "16.3px", "--sw": "37.6px" } as CSSProperties}></i><i style={{ left: "30.7%", "--t": "15.3s", "--dl": "-6.8s", "--sz": "20.4px", "--sw": "67.1px" } as CSSProperties}></i><i style={{ left: "36.9%", "--t": "12.2s", "--dl": "-18.3s", "--sz": "21.3px", "--sw": "31.6px" } as CSSProperties}></i><i style={{ left: "18.5%", "--t": "10.5s", "--dl": "-15.4s", "--sz": "13.6px", "--sw": "62.6px" } as CSSProperties}></i><i style={{ left: "5.4%", "--t": "15.4s", "--dl": "-11.0s", "--sz": "11.1px", "--sw": "39.4px" } as CSSProperties}></i><i style={{ left: "44.2%", "--t": "18.4s", "--dl": "-5.6s", "--sz": "17.3px", "--sw": "23.7px" } as CSSProperties}></i><i style={{ left: "87.0%", "--t": "12.3s", "--dl": "-15.9s", "--sz": "11.8px", "--sw": "53.3px" } as CSSProperties}></i><i style={{ left: "19.8%", "--t": "17.9s", "--dl": "-18.5s", "--sz": "22.0px", "--sw": "30.1px" } as CSSProperties}></i><i style={{ left: "72.6%", "--t": "10.2s", "--dl": "-9.2s", "--sz": "11.2px", "--sw": "60.4px" } as CSSProperties}></i><i style={{ left: "32.6%", "--t": "14.1s", "--dl": "-9.9s", "--sz": "10.1px", "--sw": "53.2px" } as CSSProperties}></i><i style={{ left: "80.5%", "--t": "12.0s", "--dl": "-14.3s", "--sz": "10.4px", "--sw": "40.6px" } as CSSProperties}></i><i style={{ left: "73.5%", "--t": "17.1s", "--dl": "-19.8s", "--sz": "18.4px", "--sw": "32.2px" } as CSSProperties}></i><i style={{ left: "3.1%", "--t": "19.0s", "--dl": "-3.8s", "--sz": "12.5px", "--sw": "35.4px" } as CSSProperties}></i><i style={{ left: "43.6%", "--t": "14.0s", "--dl": "-4.1s", "--sz": "16.1px", "--sw": "64.5px" } as CSSProperties}></i><i style={{ left: "42.4%", "--t": "15.2s", "--dl": "-14.0s", "--sz": "13.5px", "--sw": "30.1px" } as CSSProperties}></i><i style={{ left: "70.0%", "--t": "13.9s", "--dl": "-18.4s", "--sz": "21.7px", "--sw": "24.9px" } as CSSProperties}></i><i style={{ left: "26.1%", "--t": "14.8s", "--dl": "-8.9s", "--sz": "17.0px", "--sw": "20.4px" } as CSSProperties}></i><i style={{ left: "22.3%", "--t": "11.3s", "--dl": "-0.5s", "--sz": "20.2px", "--sw": "33.9px" } as CSSProperties}></i><i style={{ left: "64.1%", "--t": "15.9s", "--dl": "-12.7s", "--sz": "20.2px", "--sw": "58.2px" } as CSSProperties}></i><i style={{ left: "15.3%", "--t": "13.1s", "--dl": "-9.1s", "--sz": "16.2px", "--sw": "66.7px" } as CSSProperties}></i><i style={{ left: "3.6%", "--t": "19.2s", "--dl": "-8.0s", "--sz": "12.3px", "--sw": "44.7px" } as CSSProperties}></i><i style={{ left: "5.0%", "--t": "10.3s", "--dl": "-7.2s", "--sz": "15.4px", "--sw": "56.9px" } as CSSProperties}></i><i style={{ left: "0.4%", "--t": "10.8s", "--dl": "-2.6s", "--sz": "12.7px", "--sw": "29.1px" } as CSSProperties}></i><i style={{ left: "23.2%", "--t": "12.7s", "--dl": "-11.1s", "--sz": "21.5px", "--sw": "68.6px" } as CSSProperties}></i>
      </div>
    </>
  );
}
```

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