Skip to content

With HTML

Twelve ordinary interface elements, each brought to life by one toon class.

Edit this page

Each example below is a plain HTML element with one toon class on it, running on the screen. Press Show code to see the snippet; copy it into a page that loads toon.css and it works as shown. The demos only add page styling (colors, borders and fonts).

Under each screen, Replay plays a one-shot entrance again and Slow motion runs the example at quarter speed, so you can watch each pose. Drag the handle on the screen’s right edge to try the example at a narrower width.

Every preset here switches off when the viewer has asked for reduced motion, and one-shot entrances jump to where they end.

To make a button feel physical, add .toon-press. It dips while it’s held and springs a little past its size on release.

At the default --toon-squash of .22 it dips to 91%. Add .toon-subtle to halve that. To make it wind up on hover as well, add .toon-anticipate from the card below.

To show that a card is ready to open, add .toon-anticipate. On hover or keyboard focus it crouches, springs up and settles 4px higher.

The wind-up takes 560 ms, 70% of --toon-duration. Turn --toon-exaggeration up or down to change the crouch and the jump.

To bring a list in item by item, put .toon-follow on the list, not the items. Each item arrives 70 ms after the one above and swings past its stop before it settles (follow-through).

Set the stagger with --toon-overlap. The first 12 items stagger on their own; set --toon-i inline on later ones.

To open a dialog, popover or tooltip with a friendly bounce, add .toon-pop-in. It grows from nothing, overshoots to 127% and wobbles to rest in 800 ms.

To play a one-shot class again in your own page, remove the class, read offsetWidth and add the class back. Replay a one-shot effect shows the script, and how to do it in React, Vue and Svelte.

To slide one message in, add .toon-settle. It’s the list’s entrance for a single element: it stops, then its weight tips it back, past and level.

It starts half of --toon-distance to the left (120px by default).

To direct attention to one choice, put .toon-stage on the group. The hovered or focused child grows to 104% while the others shrink to 96% and fade to 75% opacity, still readable.

Add .is-featured to the child that should stay in focus when nothing is hovered.

To throw something into a cart, wrap it in .toon-arc. The wrapper moves sideways at a steady speed while its child rises and falls like a real throw (an arc).

Set how far it travels with --toon-distance and how high it goes with --toon-height. The throwing recipe aims at a real target with toon.js.

To make a button take off when it’s pressed, add .toon-launch. It pulls back, shoots forward --toon-distance, flies past and settles there.

It pulls back 12% of the distance and overshoots by 14px.

To hint that something new is waiting, add .toon-sway. It rocks 4° each way from its base, one swing every 2.4 seconds.

A small, slow motion like this supports the page without competing with it (secondary action).

To show that something is loading, bounce a ball with .toon-bounce and put .toon-bounce-shadow on its shadow. The ball squashes on the ground, stretches at speed and goes round at the top.

Lower --toon-height for a small loader (60px here), or add .toon-light for a quick, squashy bounce.

To make a mascot or empty state feel alive, add .toon-breathe to the body and .toon-blink to each eye. It breathes every 2 seconds and blinks every 4 seconds.

Both clocks follow --toon-duration, so one property slows the whole character down.

To fit the motion to the product, put a modifier on a container and everything inside follows. .toon-subtle halves the motion for business software, and .toon-exaggerate pushes it 1.8 times further for games.

Held down, the three buttons dip to 96%, 91% and 84%.

To start from what you want to build, see Find an effect. For every class and property, see the CSS API.