Daiwiik Harihar

Slice Text

Text

About

A movie-trailer style effect where text halves slide in from opposite directions and magnetically merge.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Slice Text to your project and fits it to your theme.

Code

How Slice Text is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { useState } from 'react';
import SliceText from "@/components/ui/slice-text";

export default function DemoOne() {
  // Manual theme state for the demo toggle
  const [isDark, setIsDark] = useState(false);

  // Toggle function to switch class on the wrapper
  const toggleTheme = () => setIsDark(!isDark);

  return (
    <div className={isDark ? 'dark' : ''}>
      <main className="relative min-h-screen w-full flex flex-col items-center justify-center p-6 transition-colors duration-500 ease-in-out bg-zinc-50 dark:bg-black overflow-hidden">
        
        {/* --- Background Pattern (Subtle Dots) --- */}
        <div className="absolute inset-0 z-0 pointer-events-none opacity-40 dark:opacity-20">
           <div className="absolute inset-0" 
                style={{ 
                  backgroundImage: `radial-gradient(${isDark ? '#333' : '#cbd5e1'} 1px, transparent 1px)`, 
                  backgroundSize: '32px 32px' 
                }} 
           />
        </div>

        {/* --- The Component Stage --- */}
        <div className="relative z-10 w-full max-w-5xl">
          <div className="transform transition-all duration-500 hover:scale-[1.01]">
             {/* The animation component */}
             <SliceText word="PERFECT SLICE" />
          </div>
        </div>

        {/* --- Floating Theme Toggle Button --- */}
        <button
          onClick={toggleTheme}
          className="fixed bottom-8 right-8 z-50 px-6 py-3 rounded-full font-medium text-sm shadow-xl transition-all duration-300
                     bg-white text-black border border-zinc-200 hover:shadow-2xl hover:-translate-y-1
                     dark:bg-zinc-900 dark:text-white dark:border-zinc-800"
        >
          {isDark ? 'Switch to Light Mode' : 'Switch to Dark Mode'}
        </button>

      </main>
    </div>
  );
}

More by Daiwiik Harihar

View all
  • Spatial Product Showcase

    Spatial Product Showcase

    2.3K
  • Perspective Tunnel Hero

    Perspective Tunnel Hero

    1.2K
  • Constellation Grid

    Constellation Grid

    1.1K
  • Focus Rail

    Focus Rail

    1.1K
  • Elastic Gallery

    Elastic Gallery

    958
  • Rolling List

    Rolling List

    929
  • Hero Shutter Text

    Hero Shutter Text

    903
  • Text Block Animation

    Text Block Animation

    859

More in Text

View all
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    110
  • Blur Reveal

    Blur Reveal

    313
  • Vapour Text Effect

    Vapour Text Effect

    2K
  • NeonRGBTextEffect

    NeonRGBTextEffect

    145
  • Rainbow Text Effect

    Rainbow Text Effect

    47
  • Shine Border

    Shine Border

    968
  • Apple Hello Effect

    Apple Hello Effect

    620
  • Text Highlight

    Text Highlight

    72