AnimationUpdated in v15

Tilt Card

A card that tilts in 3D toward the pointer.

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 { WrTilt, WrTiltCard } from 'ngwr/bits/tilt-card';

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

Playground

Hover me

Move the cursor across me.

<wr-tilt-card
  [maxTilt]="12"
  [perspective]="800"
  [scale]="1.03"
  [glare]="false"
>
  <h3>Hover me</h3>
  <p>Move the cursor across me.</p>
</wr-tilt-card>

Customize

Max Tilt (°)
12 °
Perspective (px)
800 px
Scale
1.03
Glare

Directive variant ([wrTilt])

[wrTilt] adds the same tilt to any element.

import { WrTilt } from 'ngwr/bits/tilt-card';

<img wrTilt [maxTilt]="10" [scale]="1.02" src="…" />
[wrTilt] on a plain <div> — same behaviour, no card chrome.

API

NameDescriptionTypeDefault
maxTiltMaximum tilt in degrees.number12
perspectiveCSS perspective in pixels.number800
scaleScale applied while hovered.number1.03
glareAdd a moving glare highlight overlay.booleanfalse
[wrTilt]Same inputs as <wr-tilt-card>, on any element.directive—

CSS variables

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

VariableDefaultDeclared on
--wr-tilt-card-paddingvar(--wr-space-xl).wr-tilt-card
--wr-tilt-card-radiusvar(--wr-border-radius-base).wr-tilt-card

See also