Create a beautiful and modern website design in Tailwind CSS. Use Material Icons for…
- User
Create a beautiful and modern website design in Tailwind CSS. Use Material Icons for icons.
- Assistant
Create a beautiful and modern website design in Tailwind CSS. Use Material Icons for icons.
Creating a beautiful and modern website design with Tailwind CSS and Material Icons is a great way to build a responsive and visually appealing site quickly. Below, I'll guide you through setting up Tailwind CSS, incorporating Material Icons, and provide sample code to get you started.
We'll use Tailwind CSS via npm to have full customization capabilities.
Create a new directory for your project and navigate into it:
mkdir tailwind-material-site
cd tailwind-material-site
Initialize npm:
npm init -y
Install Tailwind CSS and its dependencies:
npm install tailwindcss postcss autoprefixer
Initialize Tailwind CSS configuration:
npx tailwindcss init -p
This will create tailwind.config.js and postcss.config.js files.
Create the following folder structure:
tailwind-material-site/
├── src/
│ └── styles.css
└── public/
└── index.html
In your tailwind.config.js, set the paths to all of your template files:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./public/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [],
}
In src/styles.css, add the Tailwind directives:
@tailwind base;
@tailwind components;
@tailwind utilities;
Add a script in your package.json to build your CSS:
"scripts": {
"build": "npx tailwindcss -i ./src/styles.css -o ./public/output.css --watch"
}
Run the build process:
npm run build
We can include Material Icons via Google Fonts.
In your public/index.html, add the following <link> in the <head> section:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
Below is a sample public/index.html file demonstrating a modern design using Tailwind CSS and Material Icons.
Tailwind CSS allows extensive customization through utility classes and configuration.
bg-blue-500 or text-gray-800.py-4, px-6, mt-2, etc.text-xl, font-semibold.md:hidden, lg:flex to tailor layouts for different screen sizes.hover:bg-blue-500 and transition duration-300.theme section in tailwind.config.js.By combining Tailwind CSS with Material Icons, you can rapidly develop a aesthetically pleasing and modern website. Tailwind’s utility-first approach provides flexibility, while Material Icons offer a vast selection of icons to enhance your UI.
Feel free to customize the provided code to suit your project's needs. Happy coding!
Not yet included in a published release.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Modern Tailwind CSS Website</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Tailwind CSS -->
<link href="output.css" rel="stylesheet">
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="bg-gray-100 text-gray-800">
<!-- Navigation Bar -->
<nav class="bg-white shadow-lg">
<div class="max-w-6xl mx-auto px-4">
<div class="flex justify-between">
<div class="flex space-x-7">
<!-- Logo -->
<div>
<a href="#" class="flex items-center py-4 px-2">
<span class="material-icons text-blue-500 text-3xl">cloud</span>
<span class="font-semibold text-gray-500 text-lg">MyWebsite</span>
</a>
</div>
<!-- Primary Nav -->
<div class="hidden md:flex items-center space-x-1">
<a href="#" class="py-4 px-2 text-blue-500 border-b-4 border-blue-500 font-semibold">Home</a>
<a href="#" class="py-4 px-2 text-gray-500 hover:text-blue-500 transition duration-300">Services</a>
<a href="#" class="py-4 px-2 text-gray-500 hover:text-blue-500 transition duration-300">About</a>
<a href="#" class="py-4 px-2 text-gray-500 hover:text-blue-500 transition duration-300">Contact</a>
</div>
</div>
<!-- Secondary Nav -->
<div class="hidden md:flex items-center space-x-3 ">
<a href="" class="py-2 px-2 font-medium text-gray-500 rounded hover:bg-gray-200 transition duration-300">Log In</a>
<a href="" class="py-2 px-2 font-medium text-white bg-blue-500 rounded hover:bg-blue-400 transition duration-300">Sign Up</a>
</div>
<!-- Mobile menu button -->
<div class="md:hidden flex items-center">
<button class="outline-none mobile-menu-button">
<span class="material-icons">menu</span>
</button>
</div>
</div>
</div>
<!-- Mobile Menu -->
<div class="hidden mobile-menu">
<ul class="">
<li><a href="#" class="block text-sm px-2 py-4 text-white bg-blue-500 font-semibold">Home</a></li>
<li><a href="#services" class="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300">Services</a></li>
<li><a href="#about" class="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300">About</a></li>
<li><a href="#contact" class="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300">Contact</a></li>
</ul>
</div>
</nav>
<!-- Hero Section -->
<section class="bg-white py-20">
<div class="container mx-auto px-6">
<h2 class="text-4xl font-bold mb-2 text-gray-800">Welcome to MyWebsite</h2>
<h3 class="text-2xl mb-8 text-gray-600">We create amazing web experiences</h3>
<button class="bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-400 transition duration-300">
Get Started
</button>
</div>
</section>
<!-- Features Section -->
<section class="container mx-auto px-6 py-10">
<div class="flex flex-wrap">
<!-- Feature 1 -->
<div class="w-full md:w-1/3 p-4">
<div class="bg-white rounded-lg shadow-lg p-5">
<span class="material-icons text-blue-500 text-5xl">build</span>
<h4 class="text-xl font-semibold mt-4 mb-2">Modern Design</h4>
<p class="text-gray-600">We use the latest design trends to create stunning and modern websites.</p>
</div>
</div>
<!-- Feature 2 -->
<div class="w-full md:w-1/3 p-4">
<div class="bg-white rounded-lg shadow-lg p-5">
<span class="material-icons text-blue-500 text-5xl">code</span>
<h4 class="text-xl font-semibold mt-4 mb-2">Clean Code</h4>
<p class="text-gray-600">Our code is clean and well-organized, making it easy to maintain and update.</p>
</div>
</div>
<!-- Feature 3 -->
<div class="w-full md:w-1/3 p-4">
<div class="bg-white rounded-lg shadow-lg p-5">
<span class="material-icons text-blue-500 text-5xl">support_agent</span>
<h4 class="text-xl font-semibold mt-4 mb-2">24/7 Support</h4>
<p class="text-gray-600">We offer around-the-clock support to ensure your website runs smoothly.</p>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="bg-gray-800">
<div class="container mx-auto px-6 py-4">
<div class="flex justify-between items-center">
<div>
<a href="#" class="text-white text-2xl font-bold">MyWebsite</a>
</div>
<div class="flex space-x-4">
<a href="#" class="text-gray-400 hover:text-white">
<span class="material-icons">facebook</span>
</a>
<a href="#" class="text-gray-400 hover:text-white">
<span class="material-icons">twitter</span>
</a>
<a href="#" class="text-gray-400 hover:text-white">
<span class="material-icons">instagram</span>
</a>
</div>
</div>
<div class="mt-4 text-gray-400 text-center">
© 2023 MyWebsite. All rights reserved.
</div>
</div>
</footer>
<!-- Mobile Menu Toggle Script -->
<script>
const btn = document.querySelector('.mobile-menu-button');
const menu = document.querySelector('.mobile-menu');
btn.addEventListener('click', () => {
menu.classList.toggle('hidden');
});
</script>
</body>
</html>