DEV Community

Nihar Raote
Nihar Raote

Posted on • Edited on • Originally published at niharraoteblog.netlify.app

1

How many lines would it take to animate a button? GSAP makes it easy

In this article, I implement a simple button animation with GSAP and use the Composition API introduced in Vue 3.x. If you are not familiar with the Composition API, you can refer to the resources linked at the end of the article.

What is GSAP?

GSAP (GreenSock Animation Platform) is a JavaScript animation library that allows developers to create powerful animations with few lines of code. With this library, you get more precise control over your animations, which makes it easier to create complex animations. The GSAP library is small in size, easy to use, and works consistently across browsers with under-the-hood calculations.

Simple button animation

I have created a simple form and used GSAP to run an animation when the submit button is clicked. For this, I used the Composition API and ref from Vue. The animation itself takes only two lines of code:

Simple button animation code

Here's the codepen; you can tweak around to make some cool form animations as well:

Resources

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

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