AnimationUpdated in v15

Falling Text

Words that fall like objects and can be dragged around.

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 { WrFallingText } from 'ngwr/bits/falling-text';

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

Playground

Give it a height; the words fall to its bottom edge.

Hover this block. Each word falls and you can drag them around.
<wr-falling-text
  text="Hover this block. Each word falls and you can drag them around."
  trigger="hover"
  [highlightWords]="['Hover', 'drag']"
  [gravity]="980"
  fontSize="1.5rem"
/>

Customize

Trigger
Gravity
980
Font Size
Text

API

NameDescriptionTypeDefault
textrequiredText to render. Words are separated by spaces.string—
highlightWordsPrefix-match keywords. Matching words get the wr-falling-text__word--hl class.readonly string[][]
triggerWhen to release the words into the simulator.'auto' | 'scroll' | 'hover' | 'click''auto'
gravityGravity in pixels/sec².number980
fontSizeFont size as a CSS length.string'1rem'

See also