Presets

Slide in animation CSS

A panel that glides in from the left or right edge and settles with a soft deceleration.

CSSTailwindReactGIFMP4
Sliding in.
00.000 / 0.700s
timing
style

npm i motion · the component uses motion/react

How it works

This slide in animation moves an element in horizontally from the left or right while it fades in, and it slows down smoothly as it arrives. It fits side panels, toast notifications, chat messages, onboarding steps and image captions.

The in keyframe starts at opacity 0 with translateX(From times Distance px), where From is -1 for left and 1 for right, and ends at opacity 1 and translateX(0). One iteration, fill-mode both, and an optional Delay. Because translate is relative to where the element sits in the layout, you can slide in any element without absolute positioning.

Parameters: Width, From (Left or Right), Distance, Duration, Delay and Easing. For content that should feel like it enters from off-screen, use 200px or more; for subtle emphasis on a card, 30 to 60px is enough. Match the side to meaning: new chat messages from others come from the left, your own from the right; drawers come from the edge they are attached to. The default expo-out at 0.7s decelerates nicely.

The motion is compositor-friendly, but an element starting 80px outside its box can push past the viewport and briefly create a horizontal scrollbar. Set overflow-x: clip (or hidden) on the parent section to prevent that. For prefers-reduced-motion, keep only the opacity change.

Why does a horizontal scrollbar appear during the slide in?

At the start the element is translated outside its normal position, and if that crosses the right edge of the page the document becomes wider for a moment. Put overflow-x: clip on the containing section (clip avoids creating a scroll container, unlike hidden). The element still slides in, and the page width stays fixed.

How do I slide in from the top or bottom?

Swap translateX for translateY in the keyframe: a positive value starts below, a negative one above. The Slide up preset already does the vertical version with a stagger across several items, which suits lists. Keep this preset for horizontal panels and messages.

How do I slide the element back out?

Play the keyframe in reverse with animation-direction: reverse, or define a keyframe going to the off-screen position. Use ease-in for the exit so it accelerates away, the opposite of the entrance. In React, Motion's AnimatePresence with an exit prop of x and opacity handles both directions.

relatedMore like this

all entrance →
Hello, I faded in.
01 Fade in once
Item 1 Item 2 Item 3
02 Slide up once
I appear when scrolled into view.
03 Reveal on scroll inview
04 Equalizer bars loop
05 Typing indicator loop
06 Animated gradient background loop

Export

format
height

480p max · small watermark · 3 per day · remove limits