# Diagonal light lines

> Thin diagonal stripes slide across the screen while a band of light sweeps over them.

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

## Where to use it

Diagonal lines bring a sense of motion without adding clutter. They look good behind the pricing section of a fintech site, on the login screen of an internal dashboard or as the cover of a case study. The passing light gives the page a subtle shine. A clean animated stripes background in CSS that barely weighs anything.

Keep the lines faint if people will read long text over them, since fine stripes can shimmer on some screens. The scale slider changes the gap between lines: wide gaps look more graphic, tight ones read almost like a texture.

## Code

### HTML

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

### CSS

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

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

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

.pt-diag {
  --p: calc(15px * var(--d));
}

.pt-diag i,.pt-diag b {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg,transparent 0 calc(var(--p) - 1px),var(--lc) calc(var(--p) - 1px) var(--p));
  animation: pt-diag-m calc(4s / var(--k)) linear infinite;
}

.pt-diag i {
  --lc: color-mix(in srgb,var(--c1) 28%,transparent);
}

.pt-diag b {
  --lc: var(--c2);
  filter: drop-shadow(0 0 6px var(--c2));
  -webkit-mask: linear-gradient(135deg,transparent 40%,#000 50%,transparent 60%) 0 0/300% 300%;
  mask: linear-gradient(135deg,transparent 40%,#000 50%,transparent 60%) 0 0/300% 300%;
  animation: pt-diag-m calc(4s / var(--k)) linear infinite,pt-diag-s calc(6s / var(--k)) ease-in-out infinite;
}

.pt-diag b:nth-child(3) {
  --lc: var(--c3);
  animation-delay: 0s,calc(-3s / var(--k));
}

@keyframes pt-diag-m {
  to {
    background-position: calc(var(--p) * 1.41421) 0;
  }
}

@keyframes pt-diag-s {
  from {
    -webkit-mask-position: 100% 100%;
    mask-position: 100% 100%;
  }
  to {
    -webkit-mask-position: 0 0;
    mask-position: 0 0;
  }
}
```

### React

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

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

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

.pt-diag {
  --p: calc(15px * var(--d));
}

.pt-diag i,.pt-diag b {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg,transparent 0 calc(var(--p) - 1px),var(--lc) calc(var(--p) - 1px) var(--p));
  animation: pt-diag-m calc(4s / var(--k)) linear infinite;
}

.pt-diag i {
  --lc: color-mix(in srgb,var(--c1) 28%,transparent);
}

.pt-diag b {
  --lc: var(--c2);
  filter: drop-shadow(0 0 6px var(--c2));
  -webkit-mask: linear-gradient(135deg,transparent 40%,#000 50%,transparent 60%) 0 0/300% 300%;
  mask: linear-gradient(135deg,transparent 40%,#000 50%,transparent 60%) 0 0/300% 300%;
  animation: pt-diag-m calc(4s / var(--k)) linear infinite,pt-diag-s calc(6s / var(--k)) ease-in-out infinite;
}

.pt-diag b:nth-child(3) {
  --lc: var(--c3);
  animation-delay: 0s,calc(-3s / var(--k));
}

@keyframes pt-diag-m {
  to {
    background-position: calc(var(--p) * 1.41421) 0;
  }
}

@keyframes pt-diag-s {
  from {
    -webkit-mask-position: 100% 100%;
    mask-position: 100% 100%;
  }
  to {
    -webkit-mask-position: 0 0;
    mask-position: 0 0;
  }
}

`;

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

## What it is
Thin diagonal stripes slide across the screen while a band of light sweeps over them.

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

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

.pt-diag {
  --p: calc(15px * var(--d));
}

.pt-diag i,.pt-diag b {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg,transparent 0 calc(var(--p) - 1px),var(--lc) calc(var(--p) - 1px) var(--p));
  animation: pt-diag-m calc(4s / var(--k)) linear infinite;
}

.pt-diag i {
  --lc: color-mix(in srgb,var(--c1) 28%,transparent);
}

.pt-diag b {
  --lc: var(--c2);
  filter: drop-shadow(0 0 6px var(--c2));
  -webkit-mask: linear-gradient(135deg,transparent 40%,#000 50%,transparent 60%) 0 0/300% 300%;
  mask: linear-gradient(135deg,transparent 40%,#000 50%,transparent 60%) 0 0/300% 300%;
  animation: pt-diag-m calc(4s / var(--k)) linear infinite,pt-diag-s calc(6s / var(--k)) ease-in-out infinite;
}

.pt-diag b:nth-child(3) {
  --lc: var(--c3);
  animation-delay: 0s,calc(-3s / var(--k));
}

@keyframes pt-diag-m {
  to {
    background-position: calc(var(--p) * 1.41421) 0;
  }
}

@keyframes pt-diag-s {
  from {
    -webkit-mask-position: 100% 100%;
    mask-position: 100% 100%;
  }
  to {
    -webkit-mask-position: 0 0;
    mask-position: 0 0;
  }
}

`;

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

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