All Components
Creating Animated Links with Tailwind CSS in Next.js
This CustomLink component creates animated links that display the link text twice. When hovered, the text moves upwards with a smooth transition effect. Below is a breakdown of how the component works and how it can be used.
CustomLink Component Code
<Link>Component: TheLinkcomponent from Next.js is used to create client-side navigation. Thehrefprop defines the destination URL.groupclass: Tailwind'sgroupclass is used to target child elements for hover states. This allows you to apply hover styles to child elements when the parent is hovered.- Text movement on hover: Inside the link container, there are two
spanelements that both display the samelabeltext. Thegroup-hover:-translate-y-10class is used to move the text upwards when the parentgroupis hovered, creating a sliding effect. Thetransition duration-700class ensures the movement happens smoothly over 700 milliseconds. - Overflow hidden: The
overflow-hiddenclass ensures that any content that moves outside the boundaries of the container (due to thetranslate-yproperty) is hidden.
How to Use CustomLink
Here’s how you can use the CustomLink component in your layout:
Happy Coding 👋
Want to Learn How to Build These Components Yourself?
We have step-by-step tutorials for every component to help you create stunning interfaces with ease.
Watch Tutorials on YouTube