Published on

6 Easy Ways To Make A Outline Button With Hover Offset With Tailwind CSS

outline button with hover offset

As a FrontEnd technology blogger, you might have come across Tailwind CSS, a utility-first CSS framework that allows you to build custom designs quickly. In this article, we will explore how to create an outline button with hover offset using Tailwind CSS.

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that provides a set of pre-defined classes that you can use to style your HTML elements. It enables you to build custom designs quickly without writing any CSS code from scratch. Tailwind CSS is gaining popularity among developers because of its simplicity and flexibility.

The description of outline button with hover offset ui component

An outline button with hover offset is a user interface component that is used to highlight an action that a user can take on a web page. When a user hovers over the button, it offsets from its original position, giving a visual cue that the button is clickable. This component is commonly used in web forms, sign-up pages, and call-to-action buttons.

Why use Tailwind CSS to create an outline button with hover offset ui component?

Tailwind CSS provides a set of pre-defined classes that you can use to create an outline button with hover offset. Using Tailwind CSS, you can quickly create a custom design without writing any CSS code from scratch. Additionally, Tailwind CSS is highly customizable, which means you can adjust the design of the button to suit your needs.

The preview of outline button with hover offset ui component

Free download of the outline button with hover offset's source code

The source code of outline button with hover offset ui component

To create an outline button with hover offset using Tailwind CSS, you can use the following classes:

<div>
          <button
        class="py-2 px-4 bg-transparent text-red-600 font-semibold border border-red-600 rounded hover:bg-red-600 hover:text-white hover:border-transparent transition ease-in duration-200 transform hover:-translate-y-1 active:translate-y-0"
      >Order Now</button>
</div>

How to create a outline button with hover offset with Tailwind CSS?

To create an outline button with hover offset with Tailwind CSS, follow these six easy steps:

Step 1: Install Tailwind CSS

To use Tailwind CSS, you need to install it in your project. You can install it using npm or yarn. Here's the command to install Tailwind CSS using npm:

npm install tailwindcss

Step 2: Create a HTML file

Create a new HTML file and add the following code:

<!DOCTYPE html>
<html>
<head>
	<title>Outline Button with Hover Offset</title>
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
</head>
<body>
	<button class="bg-transparent text-blue-500 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded hover:translate-y-1 hover:shadow-lg transition-all duration-300 ease-in-out">Button</button>
</body>
</html>

Step 3: Add Tailwind CSS classes

Add the following classes to the button element:

bg-transparent
text-blue-500
font-semibold
hover:text-white
py-2
px-4
border
border-blue-500
hover:border-transparent
rounded
hover:translate-y-1
hover:shadow-lg
transition-all
duration-300
ease-in-out

Step 4: Customize the button

You can customize the button by adjusting the values of the classes. For example, you can change the background color of the button by changing the value of the bg-transparent class to bg-blue-500.

Step 5: Preview the button

Open the HTML file in your web browser to preview the button. When you hover over the button, it should offset from its original position.

Step 6: Add the button to your project

Once you're satisfied with the design of the button, you can add it to your project by copying the HTML code and pasting it into your project.

Conclusion

Creating an outline button with hover offset using Tailwind CSS is easy and straightforward. By using pre-defined classes, you can quickly create a custom design without writing any CSS code from scratch. Additionally, Tailwind CSS is highly customizable, which means you can adjust the design of the button to suit your needs.