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.
A button that squashes
Section titled “A button that squashes”To make a button feel physical, add .toon-press. It dips while it’s held and springs a little past its size on release.
Press and hold Save, then let go.
<link rel="stylesheet" href="toon.css">
<button class="toon-press">Save</button>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.
A card that winds up on hover
Section titled “A card that winds up on hover”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.
Point at the card, or tab to it.
<link rel="stylesheet" href="toon.css">
<a class="card toon-anticipate" href="#plans"> Plans <small>From $9 a month</small></a>The wind-up takes 560 ms, 70% of --toon-duration. Turn --toon-exaggeration up or down to change the crouch and the jump.
A list that settles in
Section titled “A list that settles in”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).
- Inbox
- Drafts
- Sent
Press Replay under the demo (or reload the page) to see the list arrive again.
<link rel="stylesheet" href="toon.css">
<ul class="toon-follow"> <li>Inbox</li> <li>Drafts</li> <li>Sent</li></ul>Set the stagger with --toon-overlap. The first 12 items stagger on their own; set --toon-i inline on later ones.
A dialog that pops in
Section titled “A dialog that pops in”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.
Press Replay under the demo (or reload the page) to open it again.
<link rel="stylesheet" href="toon.css">
<dialog class="toon-pop-in" open style="position:static"> Your changes are saved.</dialog>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.
A toast that settles
Section titled “A toast that settles”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.
Press Replay under the demo (or reload the page) to show it again.
<link rel="stylesheet" href="toon.css">
<div class="toon-settle" role="status">Saved</div>It starts half of --toon-distance to the left (120px by default).
Tabs that put one in focus
Section titled “Tabs that put one in focus”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.
Point at a tab, or tab to one, to put it in focus.
<link rel="stylesheet" href="toon.css">
<nav class="toon-stage"> <a href="#plans">Plans</a> <a class="is-featured" href="#pricing">Pricing</a> <a href="#faq">FAQ</a></nav>Add .is-featured to the child that should stay in focus when nothing is hovered.
Add to cart along an arc
Section titled “Add to cart along an arc”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).
Press Add to cart to throw it again.
<link rel="stylesheet" href="toon.css">
<button id="add">Add to cart</button><!-- The item rises 80px: leave room above it. --><div style="padding-top:90px; width:232px"> <div class="toon-arc" style="--toon-distance:200px; --toon-height:80px; width:32px"> <div style="width:32px; height:32px; border-radius:8px; background:var(--toon-color)"></div> </div></div>
<script>const item = document.querySelector('.toon-arc');document.getElementById('add').onclick = () => { item.classList.remove('toon-arc'); void item.offsetWidth; // let the browser see the change item.classList.add('toon-arc');};</script>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.
A send button that launches
Section titled “A send button that launches”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.
Press Send to launch it again.
<link rel="stylesheet" href="toon.css">
<div style="width:200px"> <button class="toon-launch" style="--toon-distance:60px"> Send</button></div>
<script>const send = document.querySelector('.toon-launch');send.onclick = () => { send.classList.remove('toon-launch'); void send.offsetWidth; // let the browser see the change send.classList.add('toon-launch');};</script>It pulls back 12% of the distance and overshoots by 14px.
A bell that sways
Section titled “A bell that sways”To hint that something new is waiting, add .toon-sway. It rocks 4° each way from its base, one swing every 2.4 seconds.
Watch the bell: it keeps rocking, about 2.4 seconds each way.
<link rel="stylesheet" href="toon.css">
<button class="toon-sway" aria-label="Notifications" style="padding:.5em .7em"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"> <path d="M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15z"/> <path d="M10 20.5a2 2 0 0 0 4 0"/> </svg></button>A small, slow motion like this supports the page without competing with it (secondary action).
A bouncing loader
Section titled “A bouncing loader”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.
Watch the ball squash on the ground and stretch at speed.
<link rel="stylesheet" href="toon.css">
<div role="status" aria-label="Loading" style="--toon-height:60px; display:grid; justify-items:center; padding-top:70px"> <div class="toon-solid toon-bounce" style="width:28px; height:28px"></div> <div class="toon-shadow toon-bounce-shadow" style="width:36px; height:8px"></div></div>Lower --toon-height for a small loader (60px here), or add .toon-light for a quick, squashy bounce.
An avatar that breathes and blinks
Section titled “An avatar that breathes and blinks”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.
Watch for a blink every 4 seconds.
<link rel="stylesheet" href="toon.css">
<div class="toon-breathe" style="width:72px; height:72px; border-radius:50%; background:var(--toon-color); display:flex; gap:14px; justify-content:center; padding-top:24px; box-sizing:border-box"> <span class="toon-blink" style="width:8px; height:14px; border-radius:4px; background:#222"></span> <span class="toon-blink" style="width:8px; height:14px; border-radius:4px; background:#222"></span></div>Both clocks follow --toon-duration, so one property slows the whole character down.
One button, three intensities
Section titled “One button, three intensities”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.
Press and hold each button to compare how far it dips.
<link rel="stylesheet" href="toon.css">
<div class="toon-subtle"> <button class="toon-press">Subtle</button></div><button class="toon-press">Default</button><div class="toon-exaggerate"> <button class="toon-press">Exaggerated</button></div>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.