Skip to content

Tilt

Tilt a surface toward the pointer, with optional glare, then return it to flat.

import { Tilt } from '@youj/motion'

Installation & usage

npm i @youj/motion

For an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.

Use it on one showcase surface that invites a closer look: a ticket, a pricing card, a product shot. Keep it off grids of everyday cards, text-heavy panels, where tilted type is harder to read, and anything people click with precision. For a lighter touch on many cards, use a Spotlight.

Wrap the surface, and put the rounded corners on Tilt itself. Its inner layer inherits them, so the glare clips to the same shape.

import { Tilt } from '@youj/motion'

export function Ticket() {
  return (
    <Tilt glare scale={1.02} className="rounded-2xl">
      <div className="rounded-[inherit] border bg-surface p-5">…</div>
    </Tilt>
  )
}

Reference

Propsmax, perspective, glare… (6)

Props

Tilt props
PropType
maxnumber

Maximum rotation in degrees at the edges.

default 8

8
perspectivenumber

CSS perspective distance in px.

default 900

900
glareboolean

A soft highlight that tracks the pointer.

default false

false
scalenumber

Scale while hovered.

default 1

1
springSpringToken
'snappy''smooth''settle'

default 'smooth'

'smooth'
childrenReactNode–
Other props pass through: extends HTMLAttributes<HTMLDivElement>.
MotionTilt, hover scale and glare, return · reduced motion

Motion

Motion tokens
MomentTokens
TiltrotateX and rotateY, up to max degrees at the edges
spring.smooth

0.36s, bounce 0

0.36s, bounce 0
Hover scale and glaregrow and fade in together
spring.smooth

0.36s, bounce 0

0.36s, bounce 0
Returnsprings flat when the pointer leaves
spring.smooth

0.36s, bounce 0

0.36s, bounce 0

Reduced motion

Flat and still: no rotation, no scale and no glare.

spring swaps the default for another spring token. Every value is a transform or an opacity, so a tilt never triggers layout or paint.

Reduced motion

The surface stays flat and still. There's no rotation, no hover scale and no glare, and the content reads exactly as it does at rest.

AccessibilityKeyboard, ARIA, focus

Accessibility

  • Tilt adds no roles and no focus stop. The content inside keeps its semantics, and interactive children keep their focus rings.
  • It responds to a mouse only. Touch and pen input scroll and tap as usual, and keyboard focus doesn't tilt the surface.
  • The glare layer is aria-hidden and ignores the pointer.
  • Keep max small on anything with text. Past about 10 degrees, type foreshortens enough to slow reading.