DEV Community

Cover image for Gradient animated text with Tailwind CSS
Byakkuya (ahmed zbaa)
Byakkuya (ahmed zbaa)

Posted on

1

Gradient animated text with Tailwind CSS

I've was working on a project recently and I wanted to add some cool effect on my landing page's hero section's text.
I've seen this effect on lots of sites and i want something simple because i use Tailwind css
so i find it somewhere online
and i wanted to share it with you
first you gonna add this to tailwind.config.js

modules.export = {
  theme: {
    extend: {
      animation: {
        text: 'text 5s ease infinite',
      },
      keyframes: {
        text: {
          '0%, 100%': {
            'background-size': '200% 200%',
            'background-position': 'left center',
          },
          '50%': {
            'background-size': '200% 200%',
            'background-position': 'right center',
          },
        },
      },
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

then add these classes wherever you want

<h1 class="animate-text bg-gradient-to-r from-teal-500 via-purple-500 to-orange-500 bg-clip-text text-transparent text-5xl font-black">
   Gradient animated text with Tailwind CSS
</h1>
Enter fullscreen mode Exit fullscreen mode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay