In this tutorial, we will walk you through the process of creating a simple yet modern login page using Tailwind CSS. Tailwind CSS makes it easy to create beautiful and responsive designs with minimal effort. With just a few lines of code, you can have a fully functional login form that looks great on any device.
Tailwind CSS is a utility-first CSS framework that allows you to build custom designs directly in your HTML. It’s highly customizable, mobile-friendly, and perfect for quickly prototyping designs. Whether you're building a personal project or working on a professional website, Tailwind CSS helps you save time and streamline your development process.
Here's how you can create a login page with a simple, clean design using Tailwind CSS.
First, set up the basic structure of your HTML page. Include the Tailwind CSS CDN to quickly access its classes.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="flex bg-gray-100 items-center justify-center h-screen">
<div class="p-4 border border-1 shadow bg-white w-[330px]">
<div>
<h1 class="text-3xl font-semibold">Sign In</h1>
<p>
Sign in to start your session
</p>
</div>
<div class="mt-3">
<div class="mb-3">
<label for="email">Email</label>
<input type="email" id="email" class="w-full border border-1 p-1.5" placeholder="Enter your email">
</div>
<div>
<label for="password">Password</label>
<input type="password" id="password" class="w-full border border-1 p-1.5" placeholder="Enter your password">
</div>
<a href="#" class="mt-1 text-blue-600">Forgot password?</a>
<div class="my-3">
<button type="submit" class="w-full bg-blue-600 p-2 text-white rounded-full">Submit</button>
</div>
</div>
</div>
</div>
</body>
</html>
flex
class centers the login form vertically and horizontally in the viewport, while h-screen
ensures that the form takes up the full height of the screen.You can easily modify the design by adjusting the Tailwind classes. For instance, if you want to change the color of the submit button, you can replace the bg-blue-600
class with any other color available in the Tailwind color palette.
In just 5 minutes, you’ve created a fully functional and responsive login page using Tailwind CSS! Tailwind’s utility-first approach makes it incredibly easy to design clean and modern layouts without writing a lot of custom CSS.
Happy coding!