Text Flip on Hover (Tailwind Only)

A simple text flip animation on hover component built with Tailwind CSS.

Hover Me

Examples

With Blur

Hover Me

With Skew

Adjust the translate prop to control the distance the text travels during animation. For most cases 130% is enough but for skew on large fonts, you might need to increase the translate value to prevent the text from being cut off.

Hover Me

Use in Navbar

Installation

$ npx shadcn@latest add https://akshitr.com/r/text-flip.json

Usage

import { TextFlip } from "@/components/text-flip";
 
export default function TextFlipDemo() {
  return <TextFlip text="Hello World" />;
}

Component API

TextFlip

PropTypeDefaultDescription
textstringThe text displayed and animated.
secondText?stringsame as textDifferent text to show on hover.
as?React.ElementType"div"The element or component to render as.
direction?"up" | "down""up"Direction the text slides in and out.
duration?number300Animation duration in milliseconds.
skew?booleanfalseWhether to skew the text on hover.
blur?booleanfalseWhether to blur the text on hover.
underline?booleanfalseWhether to show underline on the hover text.
translate?string"130%"How far the text travels during animation.
easing?string"cubic-bezier(0.22,1,0.36,1)"CSS easing function for the animation.
className?stringClass applied to the root element.

References