# Animated weather card

> A small weather widget where clouds drift and rain falls in the background, with the next few hours below.

- Category: [Cards](https://library.aimran.es/components/cards)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-card-weather
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A nice touch wherever the weather changes plans: the destination page of a travel agency, the booking site of a rural hotel, a surf school or an outdoor wedding venue. This animated weather widget shows temperature, conditions and an hourly forecast, with clouds and rain moving gently behind in CSS.

The scene always shows rain, so connect it to a weather API and add sunny or cloudy versions if you use it for real. As decoration on a landing page, slow the animation down; at full pace the rain can pull attention away from your headline.

## Code

### HTML

```html
<article class="uv-cweather"><div class="sky"><i></i><i></i><b style="--i:0"></b><b style="--i:1"></b><b style="--i:2"></b><b style="--i:3"></b><b style="--i:4"></b><b style="--i:5"></b><b style="--i:6"></b></div><header><span>Madrid</span><small>Now</small></header><strong>18°</strong><p>Light rain · Feels like 17°</p><footer><span>18:00 <b>17°</b></span><span>19:00 <b>16°</b></span><span>20:00 <b>15°</b></span></footer></article>
```

### CSS

```css
.uv-cweather {
  --c1: #0071e3;
  --c2: #8ec5ff;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uv-cweather {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  position: relative;
  width: 17em;
  overflow: hidden;
  padding: 1.4em;
  border-radius: 1.5em;
  font-size: var(--s);
  color: #fff;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c1) 75%,#15243a),color-mix(in srgb,var(--c2) 45%,#13202b));
  box-shadow: 0 25px 60px -30px var(--c1);
}

.uv-cweather .sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: .7;
}

.uv-cweather .sky i {
  position: absolute;
  right: -1em;
  top: 2em;
  width: 7em;
  height: 2em;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  filter: blur(4px);
  animation: uv-cw-cloud calc(8s / var(--k)) ease-in-out infinite alternate;
}

.uv-cweather .sky i+i {
  right: 5em;
  top: 4.2em;
  width: 5em;
  animation-direction: alternate-reverse;
}

.uv-cweather .sky b {
  position: absolute;
  left: calc(52% + var(--i)*6%);
  top: 6em;
  width: 1px;
  height: 1.2em;
  background: linear-gradient(transparent,rgba(255,255,255,.7));
  transform: rotate(12deg);
  animation: uv-cw-rain calc(0.9s / var(--k)) linear infinite;
  animation-delay: calc(var(--i)*-.11s);
}

.uv-cweather header,.uv-cweather>strong,.uv-cweather>p,.uv-cweather footer {
  position: relative;
}

.uv-cweather header {
  display: flex;
  justify-content: space-between;
}

.uv-cweather small {
  opacity: .6;
}

.uv-cweather>strong {
  display: block;
  margin: .45em 0 0;
  font-size: 4.4em;
  font-weight: 300;
}

.uv-cweather>p {
  margin: -.3em 0 1.5em;
  font-size: .75em;
  opacity: .7;
}

.uv-cweather footer {
  display: flex;
  border-top: 1px solid rgba(255,255,255,.18);
  padding-top: 1em;
}

.uv-cweather footer span {
  flex: 1;
  font-size: .65em;
  opacity: .65;
}

.uv-cweather footer b {
  display: block;
  margin-top: .35em;
  font-size: 1.35em;
  opacity: 1;
}

@keyframes uv-cw-cloud {
  to {
    transform: translateX(-2em);
  }
}

@keyframes uv-cw-rain {
  to {
    transform: translate(-.5em,4em) rotate(12deg);
    opacity: 0;
  }
}
```

### React

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

const css = `
.uv-cweather {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  position: relative;
  width: 17em;
  overflow: hidden;
  padding: 1.4em;
  border-radius: 1.5em;
  font-size: var(--s);
  color: #fff;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c1) 75%,#15243a),color-mix(in srgb,var(--c2) 45%,#13202b));
  box-shadow: 0 25px 60px -30px var(--c1);
}

.uv-cweather .sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: .7;
}

.uv-cweather .sky i {
  position: absolute;
  right: -1em;
  top: 2em;
  width: 7em;
  height: 2em;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  filter: blur(4px);
  animation: uv-cw-cloud calc(8s / var(--k)) ease-in-out infinite alternate;
}

.uv-cweather .sky i+i {
  right: 5em;
  top: 4.2em;
  width: 5em;
  animation-direction: alternate-reverse;
}

.uv-cweather .sky b {
  position: absolute;
  left: calc(52% + var(--i)*6%);
  top: 6em;
  width: 1px;
  height: 1.2em;
  background: linear-gradient(transparent,rgba(255,255,255,.7));
  transform: rotate(12deg);
  animation: uv-cw-rain calc(0.9s / var(--k)) linear infinite;
  animation-delay: calc(var(--i)*-.11s);
}

.uv-cweather header,.uv-cweather>strong,.uv-cweather>p,.uv-cweather footer {
  position: relative;
}

.uv-cweather header {
  display: flex;
  justify-content: space-between;
}

.uv-cweather small {
  opacity: .6;
}

.uv-cweather>strong {
  display: block;
  margin: .45em 0 0;
  font-size: 4.4em;
  font-weight: 300;
}

.uv-cweather>p {
  margin: -.3em 0 1.5em;
  font-size: .75em;
  opacity: .7;
}

.uv-cweather footer {
  display: flex;
  border-top: 1px solid rgba(255,255,255,.18);
  padding-top: 1em;
}

.uv-cweather footer span {
  flex: 1;
  font-size: .65em;
  opacity: .65;
}

.uv-cweather footer b {
  display: block;
  margin-top: .35em;
  font-size: 1.35em;
  opacity: 1;
}

@keyframes uv-cw-cloud {
  to {
    transform: translateX(-2em);
  }
}

@keyframes uv-cw-rain {
  to {
    transform: translate(-.5em,4em) rotate(12deg);
    opacity: 0;
  }
}
`;

export default function CardWeather() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <article className="uv-cweather"><div className="sky"><i></i><i></i><b style={{ "--i": "0" } as CSSProperties}></b><b style={{ "--i": "1" } as CSSProperties}></b><b style={{ "--i": "2" } as CSSProperties}></b><b style={{ "--i": "3" } as CSSProperties}></b><b style={{ "--i": "4" } as CSSProperties}></b><b style={{ "--i": "5" } as CSSProperties}></b><b style={{ "--i": "6" } as CSSProperties}></b></div><header><span>Madrid</span><small>Now</small></header><strong>18°</strong><p>Light rain · Feels like 17°</p><footer><span>18:00 <b>17°</b></span><span>19:00 <b>16°</b></span><span>20:00 <b>15°</b></span></footer></article>
      </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 “Animated weather card” block (Cards) from AIMRAN Library to my project.

## What it is
A small weather widget where clouds drift and rain falls in the background, with the next few hours below.

## Chosen settings
- Main color: #0071e3
- Secondary color: #8ec5ff
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Madrid"

## 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 = `
.uv-cweather {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  position: relative;
  width: 17em;
  overflow: hidden;
  padding: 1.4em;
  border-radius: 1.5em;
  font-size: var(--s);
  color: #fff;
  background: linear-gradient(160deg,color-mix(in srgb,var(--c1) 75%,#15243a),color-mix(in srgb,var(--c2) 45%,#13202b));
  box-shadow: 0 25px 60px -30px var(--c1);
}

.uv-cweather .sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: .7;
}

.uv-cweather .sky i {
  position: absolute;
  right: -1em;
  top: 2em;
  width: 7em;
  height: 2em;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
  filter: blur(4px);
  animation: uv-cw-cloud calc(8s / var(--k)) ease-in-out infinite alternate;
}

.uv-cweather .sky i+i {
  right: 5em;
  top: 4.2em;
  width: 5em;
  animation-direction: alternate-reverse;
}

.uv-cweather .sky b {
  position: absolute;
  left: calc(52% + var(--i)*6%);
  top: 6em;
  width: 1px;
  height: 1.2em;
  background: linear-gradient(transparent,rgba(255,255,255,.7));
  transform: rotate(12deg);
  animation: uv-cw-rain calc(0.9s / var(--k)) linear infinite;
  animation-delay: calc(var(--i)*-.11s);
}

.uv-cweather header,.uv-cweather>strong,.uv-cweather>p,.uv-cweather footer {
  position: relative;
}

.uv-cweather header {
  display: flex;
  justify-content: space-between;
}

.uv-cweather small {
  opacity: .6;
}

.uv-cweather>strong {
  display: block;
  margin: .45em 0 0;
  font-size: 4.4em;
  font-weight: 300;
}

.uv-cweather>p {
  margin: -.3em 0 1.5em;
  font-size: .75em;
  opacity: .7;
}

.uv-cweather footer {
  display: flex;
  border-top: 1px solid rgba(255,255,255,.18);
  padding-top: 1em;
}

.uv-cweather footer span {
  flex: 1;
  font-size: .65em;
  opacity: .65;
}

.uv-cweather footer b {
  display: block;
  margin-top: .35em;
  font-size: 1.35em;
  opacity: 1;
}

@keyframes uv-cw-cloud {
  to {
    transform: translateX(-2em);
  }
}

@keyframes uv-cw-rain {
  to {
    transform: translate(-.5em,4em) rotate(12deg);
    opacity: 0;
  }
}
`;

export default function CardWeather() {
  return (
    <>
      <style>{css}</style>
      <div
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <article className="uv-cweather"><div className="sky"><i></i><i></i><b style={{ "--i": "0" } as CSSProperties}></b><b style={{ "--i": "1" } as CSSProperties}></b><b style={{ "--i": "2" } as CSSProperties}></b><b style={{ "--i": "3" } as CSSProperties}></b><b style={{ "--i": "4" } as CSSProperties}></b><b style={{ "--i": "5" } as CSSProperties}></b><b style={{ "--i": "6" } as CSSProperties}></b></div><header><span>Madrid</span><small>Now</small></header><strong>18°</strong><p>Light rain · Feels like 17°</p><footer><span>18:00 <b>17°</b></span><span>19:00 <b>16°</b></span><span>20:00 <b>15°</b></span></footer></article>
      </div>
    </>
  );
}
```

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