The idea
A switch whose thumb physically deforms. Press and hold, and it squashes: wider and flatter, like something being pushed. Flip it, and it springs across the track and settles with a little overshoot. The track floods lime when it's on.
Why
Toggles are the most boring control on the web, which makes them a great place to prove a point. If one of Disney's oldest animation principles can make a toggle feel physical, it can make anything feel physical.
Squash and stretch is about mass. An object that deforms when it's pushed reads as soft and real. One that doesn't reads as a picture of an object. Your finger is pushing the thumb, so the thumb should look pushed.
Approach
- Squash on press. While the thumb is pressed it scales to 125% wide and 80% tall. That's roughly constant volume, which is what keeps it reading as "squished" rather than "resized".
- Layout animation for the travel. The thumb doesn't animate a position value. It's laid out at the start or end of the track, and Motion animates the jump between the two layouts with a stiff spring (stiffness 500, damping 22). That leaves a small overshoot, the "stretch" half of the principle.
- Color moves too, but faster. The track color fades over 250ms, quicker than the spring settles, so the state change registers before the motion finishes.
Decisions & trade-offs
- It's a real switch. It uses
role="switch"andaria-checked, so assistive tech announces it properly. The animation is layered on top and never replaces the semantics. - Transform only. The squash is a scale, not a width or height change, so it never triggers layout and stays smooth on cheap hardware.
- Subtle beats cute. The squash stops at 25%. Push it much further and the thumb starts to look broken rather than bouncy.
What I'd try next
- A drag-to-flip version, where the stretch follows your finger.
- Applying the same treatment to checkboxes and radio buttons to see where it stops working.