Slide In Text

Animates text sliding in from the left with a fade when it enters the viewport.

Component

↓ scroll

Los Flamencos National Reserve

is a nature reserve located

in the commune of San Pedro de Atacama.

The reserve covers a total area

of 740 square kilometres.

Installation

pnpm dlx shadcn@latest add "https://pulkitxm.com/components/slide-in-text.json"

Usage

Import the component

Add the SlideInText import to your file.

import { SlideInText } from "@/components/slide-in-text";

Use with default props

Wrap your text in SlideInText for the default slide-in animation.

<SlideInText>Your text here</SlideInText>;

Customize with props

Adjust left, scrub, start, and end to fine-tune the animation.

<SlideInText
  left="-400px"
  scrub={0.5}
  start="top 80%"
  end="bottom+=200px bottom"
>
  Custom animated text
</SlideInText>;

Guidelines

  • Place SlideInText inside a scrollable container (e.g. your main content area or a div with overflow-y-auto).
  • Use scrub: true for smooth scroll-linked animation, or a number (e.g. 0.5) for a slight delay.
  • Adjust left to control how far the text slides in from (e.g. -200px, -400px).
  • Customize start and end to change when the animation triggers relative to the viewport.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
childrenReact.ReactNodeContent to render inside the paragraph.
classNamestringAdditional CSS classes applied to the element.
leftstring"-200px"CSS left offset to animate from. Passed directly to GSAP.
ystringCSS y offset to animate from (e.g. '20px'). Omit for no vertical animation.
opacitynumber0Initial opacity before animation (0–1).
easestring"power3.out"GSAP ease applied to the scrub.
scrubboolean | numbertrueScrollTrigger scrub value. true = smooth, number = seconds to catch up.
startstring"0px bottom"ScrollTrigger start position.
endstring"bottom+=400px bottom"ScrollTrigger end position.

Examples

Basic

Default usage with standard scroll range and ease.

↓ scroll

Los Flamencos National Reserve

is a nature reserve located

in the commune of San Pedro de Atacama.

The reserve covers a total area

of 740 square kilometres.

import { SlideInText } from "@/components/slide-in-text";

export function SlideInTextBasic() {
  return (
    <div className="space-y-8">
      <SlideInText>First line of text</SlideInText>
    </div>
  );
}

Custom offset

Slide further with a faster scrub for snappier animation.

↓ scroll

Los Flamencos National Reserve

is a nature reserve located

in the commune of San Pedro de Atacama.

The reserve covers a total area

of 740 square kilometres.

import { SlideInText } from "@/components/slide-in-text";

export function SlideInTextCustomOffset() {
  return (
    <SlideInText left="-400px" scrub={0.5}>
      Second line
    </SlideInText>
  );
}

Custom scroll range

Control when the animation starts and ends relative to viewport.

↓ scroll

Los Flamencos National Reserve

is a nature reserve located

in the commune of San Pedro de Atacama.

The reserve covers a total area

of 740 square kilometres.

import { SlideInText } from "@/components/slide-in-text";

export function SlideInTextCustomRange() {
  return (
    <SlideInText start="top 80%" end="bottom+=200px bottom">
      Third line
    </SlideInText>
  );
}

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: