AnimationUpdated in v15

Gradient Text

Text filled with a moving gradient.

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

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

Playground

Hello, ngwr!
<wr-gradient-text
  [animationSpeed]="8"
  direction="horizontal"
  [yoyo]="true"
  [pauseOnHover]="false"
  [showBorder]="false"
>
  Hello, ngwr!
</wr-gradient-text>

Customize

Speed (s)
8.0 s
Direction
Yoyo
Pause on Hover
Border
Text

API

NameDescriptionTypeDefault
colorsGradient stops (any CSS colours).readonly string[]['#5227FF', '#FF9FFC', '#B497CF']
animationSpeedSeconds per full sweep (or per half if yoyo is on).number8
showBorderWrap the text in a surface-coloured pill with the gradient as a border ring.booleanfalse
directionGradient slide direction.'horizontal' | 'vertical' | 'diagonal''horizontal'
pauseOnHoverPause the animation while hovered.booleanfalse
yoyoBounce back-and-forth instead of restarting.booleantrue

CSS variables

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

VariableDefaultDeclared on
--wr-gradient-text-duration8s.wr-gradient-text
--wr-gradient-text-font-weightvar(--wr-font-weight-medium).wr-gradient-text
--wr-gradient-text-imagelinear-gradient(to right, #5227ff, #ff9ffc, #b497cf, #5227ff).wr-gradient-text
--wr-gradient-text-line-heightvar(--wr-leading-tight).wr-gradient-text
--wr-gradient-text-padding-xvar(--wr-space-md).wr-gradient-text
--wr-gradient-text-padding-yvar(--wr-space-xs).wr-gradient-text
--wr-gradient-text-radiusvar(--wr-border-radius-lg).wr-gradient-text
--wr-gradient-text-size300% 100%.wr-gradient-text

See also