Hanging

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/card-hanging

About this component

A shop hours card hung on a cord from a nail: brush past it and it swings, harder the faster you go, and settles on a damped pendulum; press it and the sign turns over on its cord from Open to Closed.

Dependencies
None
Difficulty
Intermediate
Reduced motion
Respected
Theme
Light and dark
Follows page color-scheme

Triggers5

  • Mouse tracking
  • Click
  • 3D
  • Spring
  • Card

Techniques4

  • requestAnimationFrame
  • Event position
  • preserve-3d
  • CSS variables

Accessibility

Keyboard and screen readers

The sign is one button whose label says what it shows and what pressing does (Shop is open, turn sign to closed); the face that is turned away is aria-hidden.

Reduced motion

The sign does not swing and turns over instantly.

Use it in anything you build, commercial and client work included. Licence

More cards

See all
InfraredGet code

What do you see?

InkblotGet code
Pear, study 4Sketchbook

Pencil, then ink · 14 Nov

InkingGet code

Salt & Iron

Wren Halloway

Hardback
312 pages

JacketGet code