02.01 · Entrance & Exit

Fade In / Fade Out

Fades in to appear and fades out to leave. Best for pop-ups and tooltips.

Watch it

It plays by itself. Turn on slow motion to see each part of the movement.

◈
Fade In
Nothing moves or changes size; it only goes from see-through to solid.

Try it

Change a setting and the animation plays again.

Speed

Slow is easy to follow. Fast feels snappy.

Feel

How the fade speeds up and slows down.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add a fade-in and fade-out to [the element you want to show and hide]. When it appears, it should go smoothly from fully transparent to fully visible, and when it leaves it should do the reverse. Nothing moves or changes size; only the opacity changes, which keeps the animation smooth because the browser doesn't need to repaint. Reserve the element's space while it is invisible so the layout doesn't jump, and make sure a hidden element can't be clicked or focused. If the visitor has reduced motion turned on, show and hide it instantly or with a very short fade. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Pop-ups
  • Tooltips
  • Loaded content
  • Image swaps

Avoid on

  • Side panels
  • Urgent alerts