AnimationAdded in v15.1

Threads

Thin lines flowing behind your content like strands in a current.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrThreads } from 'ngwr/bits/threads';

@Component({ imports: [WrThreads] })
export class MyComponent {}
Angular adaptation of an effect by David Haz / reactbits.dev.

Playground

Put it first in a positioned box; it fills that box behind the content.

Content above the threads

<section style="position: relative; min-height: 18rem">
  <wr-threads
    [lineCount]="18"
    [amplitude]="40"
    [spread]="0.4"
    [speed]="1"
    [lineWidth]="1"
  />
  <h1 style="position: relative">Content above the threads</h1>
</section>

Customize

Colour
Lines
18
Amplitude
40 px
Spread
0.40
Speed
1.0
Line width
1.00 px
Follow pointer

Behind a hero

The pointer still bends the threads under the copy, and the copy keeps every click.

Ship the quiet parts

The threads stay behind the copy, and the buttons stay clickable.

Get started
<section class="hero">
  <wr-threads [lineCount]="24" [spread]="0.6" />
  <div class="hero__content">
    <h2>Ship the quiet parts</h2>
    <p>The threads stay behind the copy, and the buttons stay clickable.</p>
    <wr-btn color="primary">Get started</wr-btn>
  </div>
</section>

<style>
  .hero { position: relative; min-height: 20rem; overflow: hidden; }
  .hero__content {
    position: relative;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1rem;
    min-height: 20rem;
    padding: 2rem;
    text-align: center;
  }
  .hero__content > * { margin: 0; }
</style>

API

NameDescriptionTypeDefault
lineCountHow many threads, rounded and kept between 1 and 100.number18
colorThread colour, any CSS colour. Emptied, it follows the theme.string'var(--wr-threads-color)'
amplitudeHow far the bundle meanders up and down, in px.number40
speedSpeed of the current; 0 holds it, a negative value reverses it.number1
lineWidthStroke width of each thread, in px.number1
spreadShare of the box height the threads fan across at their widest, 0..1.number0.4
followPointerWhether the threads near the pointer bend toward it.booleantrue

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/bits/threads's own element.

VariableDefaultDeclared on
--wr-threads-colorlight-dark(color-mix(in srgb, var(--wr-color-primary) 60%, transparent), color-mix(in srgb, var(--wr-color-primary-lighter) 60%, transparent)).wr-threads
--wr-threads-count18.wr-threads
--wr-threads-line-width1px.wr-threads
--wr-threads-spread0.4.wr-threads

See also