← Return to lab

PLAY WITH THE CODE

Web experiments

It's fun to touch. You can understand by making it.
Ideas and ways to make your site more gorgeous. Add playfulness to your screen with CSS, JavaScript, and SVG.

On each page, we will introduce the following steps: ``Moving demo → How to try it → Run it at hand → How it works → Try changing it.'' For those who understand the basics of HTML/CSS and want to try out JavaScript.

If you have some experience with HTML/CSS, start here.

At first, it works without building an environment, just by pressing a button. Open the saved HTML and try changing the touch feel and color.

CSS squishy button complete code and how to make →

Choose drawer menu, image weight reduction, and SEO based on your purpose →

SMALL INTERACTIONS

Small reactions make the site more fun.

Please click on the one that interests you. Here are four small experiments you can incorporate into your buttons and menus.

01 / Convey the status

You can immediately see that the switch has been made.

Tips to incorporate

Use this for an on/off setting. Update the label and aria-pressed along with the color, rather than relying on color alone.

button[aria-pressed="true"] { background: #fff0bc; }
02 / Create a comfortable pushing feeling

It sinks, bounces, and comes back.

Tips to incorporate

For a playful CTA. If you transform using transform, the position of the surrounding text will not change. Even if you hit repeatedly, the animation will not overlap.

Button demo and how to make →
03 / Create the joy of opening
open a small box

Thank you for finding me.
Even small reactions are part of the site's personality.

Take out the explanation when you need it.

Tips to incorporate

Useful for FAQs and extra details. HTML's details and summary elements open and close without JavaScript and support keyboard interaction.

How to make a drawer menu →
04 / Reply to operations

Still blank. Please give me a push.

Tips to incorporate

For feedback on successful operations, such as copy completion. This model only increases the number of marks when you press it, but does not save or send it. There can be up to 6 marks.

status.textContent = 'コピーしました';

None of these demos plays sound. Animations are skipped when your device requests reduced motion.

Trying out a pinch-and-throw physics calculation UI using JavaScript.

Today's topic: accessories on the desk

01 / Pinch
Drag or use the arrow keys to move. Press Enter to jump and Escape to return to the starting position.

Pinch up, down, left and right to make a pop.
When you release it, it will fall and bounce on the floor.

Also on keyboard: Select with Tab → Play with arrow keys / Enter

movement recipe

HeavyBouncy
computer color

If your device is set to reduce movement, it will stop at the position you release it from.

Behind the scenes of a small device

What creates movement is
Weight and bounce.

When you let go, it accelerates due to gravity, and when it hits the floor, it bounces upward. It gradually loses momentum and eventually stops. The higher you lift it, the thinner and smaller the shadow becomes, giving a sense of height.

Pictures are SVG, operations are Pointer Events. You can touch it the same way with your finger or mouse. Falling and bouncing are calculated only while the object is in motion.

Current settings · Implementation excerpt

This excerpt is about the idea of falling and rebounding. The implementation also includes stop judgment, wall repulsion, friction, and drag processing.

View the entire working code on GitHub ↗