Make a button clicky
-- 2 min read
We use links and buttons all the time in our websites. It would be nice if we could get a feedback from clicking the link or button instead of being left to wonder if the click actually happened. This improves the user experience of a website or application.
In this article we will learn how to make a link and button clicky. This is the experience that we want to create:
Implementation
Let's start by creating a button. The 'button' in the example above is not actually a button, but a link which is styled to look like a button.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Clicky button</title>
<style>
a {
background-color: 'orange';
padding: 12px 32px;
border-radius: 24px;
box-shadow: 4px 4px 0 0 rgba(0,0,0,0.8);
}
</style>
</head>
<body>
<a href="#contact">Contact us</a>
</body>
</html>
Now let's make it clicky by altering it's scale when the link is active, i.e when it is clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Clicky button</title>
<style>
a {
background-color: 'orange';
padding: 12px 32px;
border-radius: 24px;
box-shadow: 4px 4px 0 0 rgba(0,0,0,0.8);
}
a:active {
transform: scale(.9);
box-shadow: 0 0 #0000;
}
</style>
</head>
<body>
<a href="#contact">Contact us</a>
</body>
</html>
That's it!; The button now gives some feedback when clicked. Improve your users' experience by providing a feedback! 👋🏾