# Light rays

> Soft beams of light fan out from above and turn slowly, like sun through a church window.

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

## Where to use it

Light rays add a sense of occasion. They suit the reveal of a new product, an awards night, a choir’s website or the “thank you” page after someone buys a ticket. Two sets of beams turn slowly in opposite directions, so the light keeps shifting without drawing attention. A god rays background in CSS, no images needed.

Place the title just below the source of light, at the top center, where it gets a natural glow behind it. If the default feels too stripy on a big screen, raise the scale for fewer, wider beams.

## Code

### HTML

```html
<div class="pt-rays"><i></i><i></i></div>
```

### CSS

```css
.pt-rays {
  --c1: #0071e3;
  --c2: #8ec5ff;
  --c3: #c4b5fd;
  --k: 1;
  /* velocidad */
  --d: 1;
  /* densidad / escala */
  --o: 1;
  /* opacidad */
  --bg: #05060a;
  --fg: #ffffff;
  --blend: screen;
  min-height: 100vh;
}

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

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

.pt-rays {
  background: radial-gradient(circle at 50% -10%,color-mix(in srgb,var(--c1) 50%,var(--bg)),var(--bg) 70%)!important;
}

.pt-rays i {
  position: absolute;
  left: 50%;
  top: -10%;
  width: 220cqmax;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg,color-mix(in srgb,var(--c2) 50%,transparent) 0deg calc(4deg * var(--d)),transparent calc(4deg * var(--d)) calc(13deg * var(--d)));
  -webkit-mask: radial-gradient(circle,#000 3%,transparent 45%);
  mask: radial-gradient(circle,#000 3%,transparent 45%);
  filter: blur(6px);
  mix-blend-mode: var(--blend,screen);
  animation: pt-rays-r calc(60s / var(--k)) linear infinite;
}

.pt-rays i:nth-child(2) {
  background: repeating-conic-gradient(from 7deg,color-mix(in srgb,var(--c3) 45%,transparent) 0deg calc(3deg * var(--d)),transparent calc(3deg * var(--d)) calc(17deg * var(--d)));
  animation-duration: calc(90s / var(--k));
  animation-direction: reverse;
}

@keyframes pt-rays-r {
  to {
    rotate: 360deg;
  }
}
```

### React

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

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

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

.pt-rays {
  background: radial-gradient(circle at 50% -10%,color-mix(in srgb,var(--c1) 50%,var(--bg)),var(--bg) 70%)!important;
}

.pt-rays i {
  position: absolute;
  left: 50%;
  top: -10%;
  width: 220cqmax;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg,color-mix(in srgb,var(--c2) 50%,transparent) 0deg calc(4deg * var(--d)),transparent calc(4deg * var(--d)) calc(13deg * var(--d)));
  -webkit-mask: radial-gradient(circle,#000 3%,transparent 45%);
  mask: radial-gradient(circle,#000 3%,transparent 45%);
  filter: blur(6px);
  mix-blend-mode: var(--blend,screen);
  animation: pt-rays-r calc(60s / var(--k)) linear infinite;
}

.pt-rays i:nth-child(2) {
  background: repeating-conic-gradient(from 7deg,color-mix(in srgb,var(--c3) 45%,transparent) 0deg calc(3deg * var(--d)),transparent calc(3deg * var(--d)) calc(17deg * var(--d)));
  animation-duration: calc(90s / var(--k));
  animation-direction: reverse;
}

@keyframes pt-rays-r {
  to {
    rotate: 360deg;
  }
}

`;

export default function PatternRays() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-rays"
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--c3": "#c4b5fd",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <i></i><i></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 “Light rays” block (Backgrounds) from AIMRAN Library to my project.

## What it is
Soft beams of light fan out from above and turn slowly, like sun through a church window.

## Chosen settings
- Color 1: #0071e3
- Color 2: #8ec5ff
- Color 3: #c4b5fd
- 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-rays {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

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

.pt-rays {
  background: radial-gradient(circle at 50% -10%,color-mix(in srgb,var(--c1) 50%,var(--bg)),var(--bg) 70%)!important;
}

.pt-rays i {
  position: absolute;
  left: 50%;
  top: -10%;
  width: 220cqmax;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg,color-mix(in srgb,var(--c2) 50%,transparent) 0deg calc(4deg * var(--d)),transparent calc(4deg * var(--d)) calc(13deg * var(--d)));
  -webkit-mask: radial-gradient(circle,#000 3%,transparent 45%);
  mask: radial-gradient(circle,#000 3%,transparent 45%);
  filter: blur(6px);
  mix-blend-mode: var(--blend,screen);
  animation: pt-rays-r calc(60s / var(--k)) linear infinite;
}

.pt-rays i:nth-child(2) {
  background: repeating-conic-gradient(from 7deg,color-mix(in srgb,var(--c3) 45%,transparent) 0deg calc(3deg * var(--d)),transparent calc(3deg * var(--d)) calc(17deg * var(--d)));
  animation-duration: calc(90s / var(--k));
  animation-direction: reverse;
}

@keyframes pt-rays-r {
  to {
    rotate: 360deg;
  }
}

`;

export default function PatternRays() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-rays"
        style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--c3": "#c4b5fd",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <i></i><i></i>
      </div>
    </>
  );
}
```

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