浏览所有可用的 Tailwind CSS 组件
一个专注于微交互和支持深色主题的响应式大菜单组件,使用 Tailwind CSS 设计。
<div class="relative bg-white dark:bg-gray-800"> <nav class="flex flex-col md:flex-row justify-between items-center p-4"> <div class="flex items-center"> <a href="#" class="text-lg font-semibold text-gray-800 dark:text-white hover:text-blue-500 dark:hover:text-blue-400 transition duration-150 ease-in-out">Brand</a> <div class="hidden md:flex space-x-4 ml-8"> <a href="#" class="text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition duration-150 ease-in-out">Home</a> <div class="relative group"> <a href="#" class="text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition duration-150 ease-in-out">Services</a> <div class="absolute left-0 hidden mt-2 w-48 bg-white dark:bg-gray-900 shadow-lg rounded-lg group-hover:block transition duration-150 ease-in-out"> <ul class="py-2"> <li class="px-4 py-2 hover:bg-blue-100 dark:hover:bg-gray-700"><a href="#" class="block text-gray-800 dark:text-gray-300">Web Design</a></li> <li class="px-4 py-2 hover:bg-blue-100 dark:hover:bg-gray-700"><a href="#" class="block text-gray-800 dark:text-gray-300">SEO</a></li> <li class="px-4 py-2 hover:bg-blue-100 dark:hover:bg-gray-700"><a href="#" class="block text-gray-800 dark:text-gray-300">Content Writing</a></li> </ul> </div> </div> <a href="#" class="text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 transition duration-150 ease-in-out">About Us</a> </div> </div> <div class="md:hidden"> <button class="text-gray-600 dark:text-gray-300 focus:outline-none hover:text-blue-500 dark:hover:text-blue-400 transition duration-150 ease-in-out"> <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"/> </svg> </button> </div> </nav> <div class="mt-4 max-w-6xl mx-auto px-2"> <div class="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-6"> <div class="bg-white dark:bg-gray-900 rounded-lg shadow-md p-6 transition duration-150 ease-in-out hover:shadow-lg"> <img src="https://picsum.photos/200/150?random=1" alt="Placeholder" class="rounded mb-4" /> <h3 class="text-lg font-semibold text-gray-800 dark:text-white">Service One</h3> <p class="text-gray-600 dark:text-gray-300">Some description of the service offered.</p> </div> <div class="bg-white dark:bg-gray-900 rounded-lg shadow-md p-6 transition duration-150 ease-in-out hover:shadow-lg"> <img src="https://picsum.photos/200/150?random=2" alt="Placeholder" class="rounded mb-4" /> <h3 class="text-lg font-semibold text-gray-800 dark:text-white">Service Two</h3> <p class="text-gray-600 dark:text-gray-300">Some description of the service offered.</p> </div> <div class="bg-white dark:bg-gray-900 rounded-lg shadow-md p-6 transition duration-150 ease-in-out hover:shadow-lg"> <img src="https://picsum.photos/200/150?random=3" alt="Placeholder" class="rounded mb-4" /> <h3 class="text-lg font-semibold text-gray-800 dark:text-white">Service Three</h3> <p class="text-gray-600 dark:text-gray-300">Some description of the service offered.</p> </div> <div class="bg-white dark:bg-gray-900 rounded-lg shadow-md p-6 transition duration-150 ease-in-out hover:shadow-lg"> <img src="https://picsum.photos/200/150?random=4" alt="Placeholder" class="rounded mb-4" /> <h3 class="text-lg font-semibold text-gray-800 dark:text-white">Service Four</h3> <p class="text-gray-600 dark:text-gray-300">Some description of the service offered.</p> </div> </div> </div> </div>
一个响应式注册表单组件,采用玻璃质感设计,具有磨砂玻璃般的半透明元素和模糊效果,支持深色模式并显示占位图像。
<div class="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-900"> <form class="bg-white dark:bg-gray-800 rounded-lg shadow-lg backdrop-blur-md p-8 w-full max-w-md"> <h2 class="text-2xl font-semibold text-gray-800 dark:text-white text-center mb-6">Register</h2> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300 mb-2" for="username">Username</label> <input class="block w-full px-4 py-2 border rounded-md focus:ring focus:ring-blue-500 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-500" type="text" id="username" placeholder="Your Username" required /> </div> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300 mb-2" for="email">Email</label> <input class="block w-full px-4 py-2 border rounded-md focus:ring focus:ring-blue-500 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-500" type="email" id="email" placeholder="Your Email" required /> </div> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300 mb-2" for="password">Password</label> <input class="block w-full px-4 py-2 border rounded-md focus:ring focus:ring-blue-500 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-500" type="password" id="password" placeholder="Your Password" required /> </div> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300 mb-2" for="avatar">Avatar</label> <div class="flex items-center"> <img src="https://picsum.photos/50" alt="Avatar" class="rounded-full mr-3 border-2 border-gray-300 dark:border-gray-600" /> <input class="block w-full px-4 py-2 border rounded-md focus:ring focus:ring-blue-500 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-500" type="text" id="avatar" value="https://randomuser.me/api/portraits/men/10.jpg" readonly /> </div> </div> <button class="w-full bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-4 rounded-md shadow focus:outline-none focus:ring focus:ring-blue-500 mt-4">Register</button> </form> </div>
一个采用玻璃质感设计的登录表单组件,具有磨砂玻璃般的半透明元素和响应效果,支持深色主题,使用 Tailwind CSS。
<div class="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-900"> <div class="bg-white dark:bg-gray-800 bg-opacity-40 backdrop-blur-lg rounded-lg shadow-lg p-8 max-w-md w-full"> <h2 class="text-2xl font-bold text-center text-gray-800 dark:text-gray-200 mb-6">Login</h2> <form> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300 mb-2" for="username">Username</label> <input class="block w-full px-4 py-2 border rounded-md bg-transparent border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-200 focus:outline-none focus:ring focus:ring-blue-500 dark:focus:ring-blue-400" type="text" id="username" placeholder="Enter your username" required> </div> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300 mb-2" for="password">Password</label> <input class="block w-full px-4 py-2 border rounded-md bg-transparent border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-200 focus:outline-none focus:ring focus:ring-blue-500 dark:focus:ring-blue-400" type="password" id="password" placeholder="Enter your password" required> </div> <div class="flex items-center justify-between mb-4"> <div class="flex items-center"> <input type="checkbox" class="form-checkbox h-4 w-4 text-blue-600 transition duration-150 ease-in-out"> <label class="ml-2 text-sm text-gray-600 dark:text-gray-300">Remember me</label> </div> <a href="#" class="text-sm text-blue-600 hover:underline dark:text-blue-400">Forgot password?</a> </div> <button type="submit" class="w-full bg-blue-600 hover:bg-blue-500 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">Login</button> </form> <p class="mt-6 text-center text-gray-600 dark:text-gray-400">Don't have an account? <a href="#" class="text-blue-600 hover:underline dark:text-blue-400">Sign up</a></p> </div> </div>
一个使用 Tailwind CSS 设计的响应式表单组件,遵循材料设计原则,支持深色模式。
<div class="container mx-auto p-6"> <h2 class="text-2xl font-bold mb-6 text-gray-900 dark:text-white">Contact Us</h2> <form class="bg-white dark:bg-gray-800 shadow-md rounded-lg p-8"> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300" for="name">Name</label> <input class="w-full p-3 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-500" id="name" type="text" placeholder="Your Name" required> </div> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300" for="email">Email</label> <input class="w-full p-3 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-500" id="email" type="email" placeholder="Your Email" required> </div> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300" for="message">Message</label> <textarea class="w-full p-3 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-500" id="message" rows="4" placeholder="Your Message" required></textarea> </div> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-300">Avatar</label> <img class="rounded-full w-20 h-20 mb-2 border border-gray-300" src="https://randomuser.me/api/portraits/men/1.jpg" alt="Avatar"> </div> <button class="w-full p-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 focus:outline-none focus:ring focus:ring-blue-500 dark:bg-blue-700 dark:hover:bg-blue-600">Submit</button> </form> </div> <style> @media (prefers-color-scheme: dark) { body { background-color: #1E1E2F; } } </style>
一个基于材料设计原则的加载器组件,支持深色模式和响应效果,兼容 Tailwind CSS。
<div class="flex flex-col items-center justify-center h-screen bg-gray-100 dark:bg-gray-800"> <h1 class="text-2xl font-bold mb-8 text-gray-800 dark:text-white">Loading...</h1> <div class="flex items-center justify-center space-x-4"> <div class="loader w-16 h-16 border-4 border-blue-500 rounded-full border-t-transparent animate-spin"></div> <div class="loader w-16 h-16 border-4 border-green-500 rounded-full border-t-transparent animate-spin"></div> <div class="loader w-16 h-16 border-4 border-red-500 rounded-full border-t-transparent animate-spin"></div> </div> <div class="mt-8"> <img class="w-24 h-24 rounded-full shadow-lg" src="https://picsum.photos/100/100" alt="Random Image" /> </div> <div class="mt-2 text-sm text-gray-500 dark:text-gray-400">This is an example of a loading component with material design.</div> </div> <style> @tailwind base; @tailwind components; @tailwind utilities; .loader { @apply animate-spin; } @media (prefers-color-scheme: dark) { /* Dark mode styles */ .loader { filter: brightness(1.2); } } </style>
一个使用 Tailwind CSS 设计的响应式导航栏组件,采用拟物风格,支持深色主题。
<nav class="bg-gray-200 dark:bg-gray-800 p-4 rounded-lg shadow-lg"> <div class="container mx-auto flex justify-between items-center"> <div class="flex items-center space-x-4"> <img src="https://picsum.photos/50/50?random=1" alt="Logo" class="h-10 rounded-full"> <span class="text-xl font-bold dark:text-white">Brand</span> </div> <div class="hidden md:flex space-x-4"> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> Home </a> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> About </a> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> Services </a> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> Contact </a> </div> <div class="md:hidden flex items-center"> <button class="text-gray-800 dark:text-gray-200 p-2 rounded-lg focus:outline-none"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-6 h-6"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7" /> </svg> </button> </div> </div> <div class="md:hidden"> <div class="flex flex-col space-y-1 mt-2"> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> Home </a> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> About </a> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> Services </a> <a href="#" class="text-gray-800 dark:text-gray-200 p-2 rounded-lg transition duration-200 hover:bg-gray-300 dark:hover:bg-gray-700"> Contact </a> </div> </div> </nav>
一个响应式列组件,遵循材料设计原则,使用 Tailwind CSS 进行样式设计,支持深色主题和响应式动画。
<div class="container mx-auto px-4"> <h2 class="text-2xl font-bold my-6 text-gray-800 dark:text-gray-200">Columns Component</h2> <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6"> <div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300"> <img src="https://picsum.photos/200/150?random=1" alt="Placeholder" class="w-full h-48 rounded-md object-cover mb-4"> <h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Column 1</h3> <p class="text-gray-600 dark:text-gray-400">This is a description for the first column. It can contain any content.</p> </div> <div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300"> <img src="https://picsum.photos/200/150?random=2" alt="Placeholder" class="w-full h-48 rounded-md object-cover mb-4"> <h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Column 2</h3> <p class="text-gray-600 dark:text-gray-400">This is a description for the second column. It can contain any content.</p> </div> <div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300"> <img src="https://picsum.photos/200/150?random=3" alt="Placeholder" class="w-full h-48 rounded-md object-cover mb-4"> <h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Column 3</h3> <p class="text-gray-600 dark:text-gray-400">This is a description for the third column. It can contain any content.</p> </div> <div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300"> <img src="https://picsum.photos/200/150?random=4" alt="Placeholder" class="w-full h-48 rounded-md object-cover mb-4"> <h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Column 4</h3> <p class="text-gray-600 dark:text-gray-400">This is a description for the fourth column. It can contain any content.</p> </div> <div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300"> <img src="https://picsum.photos/200/150?random=5" alt="Placeholder" class="w-full h-48 rounded-md object-cover mb-4"> <h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Column 5</h3> <p class="text-gray-600 dark:text-gray-400">This is a description for the fifth column. It can contain any content.</p> </div> <div class="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300"> <img src="https://picsum.photos/200/150?random=6" alt="Placeholder" class="w-full h-48 rounded-md object-cover mb-4"> <h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Column 6</h3> <p class="text-gray-600 dark:text-gray-400">This is a description for the sixth column. It can contain any content.</p> </div> </div> </div>
一个复古/旧式风格的登录表单组件,具有响应效果和深色主题支持,使用 Tailwind CSS 设计。
<div class="flex items-center justify-center min-h-screen bg-gradient-to-r from-purple-500 to-pink-500 dark:from-purple-800 dark:to-pink-800"> <div class="bg-white rounded-lg shadow-lg p-8 max-w-sm w-full dark:bg-gray-800"> <h2 class="text-2xl font-bold text-center text-purple-700 dark:text-purple-300 mb-6">Login to Your Account</h2> <form> <div class="mb-4"> <label class="block text-gray-700 dark:text-gray-200 mb-1" for="email">Email</label> <input type="email" id="email" placeholder="[email protected]" class="w-full p-2 border border-gray-300 rounded-lg dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200" required /> </div> <div class="mb-6"> <label class="block text-gray-700 dark:text-gray-200 mb-1" for="password">Password</label> <input type="password" id="password" placeholder="********" class="w-full p-2 border border-gray-300 rounded-lg dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200" required /> </div> <button type="submit" class="w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 rounded-lg transition duration-300 dark:bg-purple-700 dark:hover:bg-purple-800">Login</button> </form> <p class="text-center text-gray-600 dark:text-gray-400 mt-4"> <a href="#" class="hover:underline">Forgot Password?</a> </p> <div class="flex items-center justify-center mt-4"> <img src="https://picsum.photos/40/40" alt="Placeholder Avatar" class="rounded-full mr-2" /> <span class="text-gray-700 dark:text-gray-300">Login with Random User</span> </div> </div> </div>
一个使用 Tailwind CSS 设计的极简社交分享按钮组件,具有响应式布局和深色主题支持。该组件包括用于在流行社交媒体平台上分享的按钮,采用干净简单的设计元素。
<div class="flex flex-col md:flex-row justify-center items-center space-x-4 p-4 bg-white dark:bg-gray-800 rounded-lg shadow"> <div class="flex items-center space-x-2"> <img src="https://picsum.photos/30" alt="Avatar" class="w-8 h-8 rounded-full" /> <span class="text-gray-800 dark:text-gray-200">Share with:</span> </div> <a href="#" class="flex items-center justify-center w-10 h-10 rounded-full bg-blue-500 hover:bg-blue-600 text-white transition duration-200 ease-in-out"> <img src="https://img.icons8.com/ios-filled/50/ffffff/facebook-new.png" alt="Facebook" class="w-6 h-6" /> </a> <a href="#" class="flex items-center justify-center w-10 h-10 rounded-full bg-blue-400 hover:bg-blue-500 text-white transition duration-200 ease-in-out"> <img src="https://img.icons8.com/ios-filled/50/ffffff/twitter-squared.png" alt="Twitter" class="w-6 h-6" /> </a> <a href="#" class="flex items-center justify-center w-10 h-10 rounded-full bg-red-500 hover:bg-red-600 text-white transition duration-200 ease-in-out"> <img src="https://img.icons8.com/ios-filled/50/ffffff/instagram-new.png" alt="Instagram" class="w-6 h-6" /> </a> <a href="#" class="flex items-center justify-center w-10 h-10 rounded-full bg-gray-800 hover:bg-gray-600 text-white transition duration-200 ease-in-out"> <img src="https://img.icons8.com/ios-filled/50/ffffff/linkedin.png" alt="LinkedIn" class="w-6 h-6" /> </a> </div>
一个以80年代/90年代复古/经典美学风格设计的响应式社交分享按钮组件,具备深色主题支持,使用 Tailwind CSS 和占位符图像。
<div class="flex flex-col items-center justify-center p-5 bg-gradient-to-r from-purple-500 to-pink-500 dark:from-purple-800 dark:to-pink-700 rounded-lg shadow-lg"> <h2 class="text-white text-2xl font-bold mb-4">Share Your Experience</h2> <div class="flex space-x-4"> <a href="#" class="flex items-center p-2 bg-white dark:bg-gray-800 border-2 border-gray-300 dark:border-gray-600 rounded-full transition-transform transform hover:scale-105"> <img src="https://picsum.photos/30/30" alt="facebook" class="w-8 h-8 rounded-full mr-2"> <span class="text-gray-800 dark:text-white font-medium">Facebook</span> </a> <a href="#" class="flex items-center p-2 bg-white dark:bg-gray-800 border-2 border-gray-300 dark:border-gray-600 rounded-full transition-transform transform hover:scale-105"> <img src="https://picsum.photos/30/30" alt="twitter" class="w-8 h-8 rounded-full mr-2"> <span class="text-gray-800 dark:text-white font-medium">Twitter</span> </a> <a href="#" class="flex items-center p-2 bg-white dark:bg-gray-800 border-2 border-gray-300 dark:border-gray-600 rounded-full transition-transform transform hover:scale-105"> <img src="https://picsum.photos/30/30" alt="instagram" class="w-8 h-8 rounded-full mr-2"> <span class="text-gray-800 dark:text-white font-medium">Instagram</span> </a> <a href="#" class="flex items-center p-2 bg-white dark:bg-gray-800 border-2 border-gray-300 dark:border-gray-600 rounded-full transition-transform transform hover:scale-105"> <img src="https://picsum.photos/30/30" alt="linkedin" class="w-8 h-8 rounded-full mr-2"> <span class="text-gray-800 dark:text-white font-medium">LinkedIn</span> </a> </div> <div class="mt-5"> <img src="https://randomuser.me/api/portraits/men/1.jpg" alt="User Avatar" class="w-16 h-16 rounded-full border-2 border-white shadow-lg"> </div> </div>