浏览所有可用的 Tailwind CSS 组件
一个导航组件,采用复古/乡土设计,单色配色方案,适用于仪表板。包括链接,并支持黑暗模式。
<nav class="bg-gray-800 p-4 shadow-md"> <div class="flex justify-between items-center"> <div class="text-white text-lg font-bold">Retro Dashboard</div> <div class="hidden md:flex space-x-4"> <a href="#" class="text-gray-300 hover:text-white">Home</a> <a href="#" class="text-gray-300 hover:text-white">Data</a> <a href="#" class="text-gray-300 hover:text-white">Settings</a> <a href="#" class="text-gray-300 hover:text-white">Profile</a> </div> <div class="md:hidden"> <button class="text-gray-300 hover:text-white"> <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7" /> </svg> </button> </div> </div> <div class="mt-4 md:hidden"> <a href="#" class="block text-gray-300 hover:text-white">Home</a> <a href="#" class="block text-gray-300 hover:text-white">Data</a> <a href="#" class="block text-gray-300 hover:text-white">Settings</a> <a href="#" class="block text-gray-300 hover:text-white">Profile</a> </div> </nav> <div class="p-4"> <h2 class="text-white text-2xl mb-4">Dashboard Overview</h2> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"> <div class="bg-gray-700 p-4 rounded-md shadow-md"> <img src="https://picsum.photos/400/300?random=1" alt="Random Image" class="w-full h-32 object-cover rounded-md"> <h3 class="text-white mt-2">Data Point 1</h3> <p class="text-gray-300">Description of data point 1.</p> </div> <div class="bg-gray-700 p-4 rounded-md shadow-md"> <img src="https://picsum.photos/400/300?random=2" alt="Random Image" class="w-full h-32 object-cover rounded-md"> <h3 class="text-white mt-2">Data Point 2</h3> <p class="text-gray-300">Description of data point 2.</p> </div> <div class="bg-gray-700 p-4 rounded-md shadow-md"> <img src="https://picsum.photos/400/300?random=3" alt="Random Image" class="w-full h-32 object-cover rounded-md"> <h3 class="text-white mt-2">Data Point 3</h3> <p class="text-gray-300">Description of data point 3.</p> </div> </div> </div>
一个响应式按钮组件,支持投资组合的黑暗模式。具有极简的平面设计,采用灰阶,复杂性适中。
<div class="flex flex-col items-center justify-center gap-4 p-8 bg-gray-100 dark:bg-gray-900 min-h-screen"> <!-- Primary Button --> <button class="px-6 py-3 text-lg font-semibold text-white bg-gray-800 rounded-md shadow-md transition duration-300 ease-in-out hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-opacity-50 dark:bg-gray-200 dark:text-gray-900 dark:hover:bg-gray-300 dark:focus:ring-gray-400"> Primary Action </button> <!-- Secondary Button --> <button class="px-6 py-3 text-lg font-semibold text-gray-800 bg-transparent border-2 border-gray-800 rounded-md shadow-md transition duration-300 ease-in-out hover:bg-gray-800 hover:text-white focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-opacity-50 dark:text-gray-200 dark:border-gray-200 dark:hover:bg-gray-200 dark:hover:text-gray-900 dark:focus:ring-gray-400"> Secondary Action </button> <!-- Tertiary Button (Icon only example) --> <button class="flex items-center justify-center w-12 h-12 text-gray-800 bg-transparent border-2 border-gray-800 rounded-full shadow-md transition duration-300 ease-in-out hover:bg-gray-800 hover:text-white focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-opacity-50 dark:text-gray-200 dark:border-gray-200 dark:hover:bg-gray-200 dark:hover:text-gray-900 dark:focus:ring-gray-400"> <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" /> </svg> </button> <!-- Responsive Example (adjusts layout on larger screens) --> <div class="flex flex-col md:flex-row items-center justify-center gap-4 w-full"> <button class="w-full md:w-auto px-6 py-3 text-lg font-semibold text-white bg-gray-800 rounded-md shadow-md transition duration-300 ease-in-out hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-opacity-50 dark:bg-gray-200 dark:text-gray-900 dark:hover:bg-gray-300 dark:focus:ring-gray-400"> Responsive Button 1 </button> <button class="w-full md:w-auto px-6 py-3 text-lg font-semibold text-gray-800 bg-transparent border-2 border-gray-800 rounded-md shadow-md transition duration-300 ease-in-out hover:bg-gray-800 hover:text-white focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-opacity-50 dark:text-gray-200 dark:border-gray-200 dark:hover:bg-gray-200 dark:hover:text-gray-900 dark:focus:ring-gray-400"> Responsive Button 2 </button> </div> </div>
一个响应式徽章组件,具有3D设计、类似色彩方案、适中的复杂性和仪表板的黑暗主题支持。仅使用Tailwind CSS类。
<div class="flex flex-wrap gap-2 p-4 bg-gray-100 dark:bg-gray-800 rounded-lg shadow-lg"> <!-- Badge 1 --> <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gradient-to-br from-teal-400 to-teal-600 text-white shadow-md dark:from-teal-600 dark:to-teal-800"> <svg class="w-4 h-4 mr-1" 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="M5 13l4 4L19 7"></path></svg> Completed </span> <!-- Badge 2 --> <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gradient-to-br from-red-400 to-red-600 text-white shadow-md dark:from-red-600 dark:to-red-800"> <svg class="w-4 h-4 mr-1" 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="M6 18L18 6M6 6l12 12"></path></svg> Failed </span> <!-- Badge 3 --> <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gradient-to-br from-yellow-400 to-yellow-600 text-white shadow-md dark:from-yellow-600 dark:to-yellow-800"> <svg class="w-4 h-4 mr-1" 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="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> Pending </span> <!-- Badge 4 - Example with icon and no text --> <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gradient-to-br from-blue-400 to-blue-600 text-white shadow-md dark:from-blue-600 dark:to-blue-800"> <svg class="w-4 h-4" 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="M13 10V3L4 14h7v7l9-11h-7z"></path></svg> </span> </div>
响应式登录/注册组件,支持黑暗模式
<div class="min-h-screen flex items-center justify-center bg-gray-900"> <div class="bg-gray-800 p-8 rounded-lg shadow-xl w-full max-w-md"> <div class="tabs mb-6"> <button class="w-1/2 py-2 text-lg font-semibold text-center text-white border-b-2 border-pink-500">Login</button> <button class="w-1/2 py-2 text-lg font-semibold text-center text-gray-400 hover:text-white">Sign Up</button> </div> <form> <div class="mb-4"> <label for="email" class="block text-gray-400 text-sm font-bold mb-2">Email</label> <input type="email" id="email" class="shadow appearance-none border border-gray-700 rounded w-full py-2 px-3 text-white bg-gray-700 focus:outline-none focus:ring-pink-500 focus:border-pink-500" placeholder="Email"> </div> <div class="mb-6"> <label for="password" class="block text-gray-400 text-sm font-bold mb-2">Password</label> <input type="password" id="password" class="shadow appearance-none border border-gray-700 rounded w-full py-2 px-3 text-white bg-gray-700 focus:outline-none focus:ring-pink-500 focus:border-pink-500" placeholder="Password"> </div> <div class="flex items-center justify-between"> <button class="bg-pink-500 hover:bg-pink-600 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" type="button"> Login </button> <a class="inline-block align-baseline font-bold text-sm text-pink-500 hover:text-pink-600" href="#"> Forgot Password? </a> </div> </form> </div> </div>
一个简单的拟态风格警报消息组件,适用于商业网站,具有鲜艳的色彩和响应式黑暗主题支持,使用Tailwind CSS,无需JavaScript。
<div class="flex items-center justify-center h-screen bg-gray-200 dark:bg-gray-800"> <div class="p-6 rounded-xl shadow-xl bg-gray-300 dark:bg-gray-700 dark:shadow-xl-dark"> <div class="flex items-center"> <div class="flex-shrink-0"> <svg class="h-6 w-6 text-green-500 dark:text-green-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /> </svg> </div> <div class="ml-3"> <p class="text-sm leading-5 font-medium text-gray-900 dark:text-gray-100"> Successfully updated! </p> </div> </div> </div> </div>
一个响应式的社交分享按钮组件,采用拟物风格的灰阶设计,适用于博客内容消费。包括黑暗模式支持。
<div class="flex flex-col items-center bg-gray-100 dark:bg-gray-800 p-6 rounded-lg shadow-lg max-w-md mx-auto"> <h2 class="text-xl font-bold text-gray-800 dark:text-gray-200 mb-4">Share This Article</h2> <div class="flex space-x-4 mb-6"> <div class="bg-gray-300 dark:bg-gray-700 p-3 rounded-full shadow hover:shadow-lg transform hover:scale-105 transition-transform duration-200"> <img src="https://picsum.photos/40/40?random=1" alt="Facebook" class="w-10 h-10 rounded-full"> <a href="#" class="block text-center text-sm text-gray-800 dark:text-gray-200">Facebook</a> </div> <div class="bg-gray-300 dark:bg-gray-700 p-3 rounded-full shadow hover:shadow-lg transform hover:scale-105 transition-transform duration-200"> <img src="https://picsum.photos/40/40?random=2" alt="Twitter" class="w-10 h-10 rounded-full"> <a href="#" class="block text-center text-sm text-gray-800 dark:text-gray-200">Twitter</a> </div> <div class="bg-gray-300 dark:bg-gray-700 p-3 rounded-full shadow hover:shadow-lg transform hover:scale-105 transition-transform duration-200"> <img src="https://picsum.photos/40/40?random=3" alt="LinkedIn" class="w-10 h-10 rounded-full"> <a href="#" class="block text-center text-sm text-gray-800 dark:text-gray-200">LinkedIn</a> </div> <div class="bg-gray-300 dark:bg-gray-700 p-3 rounded-full shadow hover:shadow-lg transform hover:scale-105 transition-transform duration-200"> <img src="https://picsum.photos/40/40?random=4" alt="Email" class="w-10 h-10 rounded-full"> <a href="#" class="block text-center text-sm text-gray-800 dark:text-gray-200">Email</a> </div> </div> <p class="text-gray-600 dark:text-gray-400 text-center text-sm">Share this with your friends and family!</p> </div>
一个简单的评论区组件,采用复古/乡土色彩美学设计。它具有怀旧的设计,令人想起80年代和90年代,专为社交媒体界面量身定制,支持黑暗模式。
<div class="bg-gray-50 dark:bg-gray-800 p-6 rounded-lg shadow-md"> <h2 class="text-2xl font-bold text-brown-800 dark:text-brown-200 mb-4">Comments</h2> <div class="flex mb-4"> <img src="https://randomuser.me/api/portraits/men/1.jpg" alt="User Avatar" class="rounded-full w-12 h-12 mr-4"> <div class="flex-1"> <input type="text" placeholder="Write a comment..." class="w-full bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-gray-100 p-2 rounded-lg shadow border border-gray-300 dark:border-gray-600 placeholder-gray-600 dark:placeholder-gray-400 focus:ring focus:ring-brown-300 dark:focus:ring-brown-500"/> </div> </div> <div class="border-t border-gray-300 dark:border-gray-600 pt-4"> <div class="flex items-start mb-4"> <img src="https://randomuser.me/api/portraits/women/2.jpg" alt="User Avatar" class="rounded-full w-10 h-10 mr-3"> <div class="bg-gray-100 dark:bg-gray-700 p-2 rounded-lg shadow"> <p class="text-brown-800 dark:text-brown-200"><strong>Alice</strong> <span class="text-gray-600 dark:text-gray-400">- 2 hours ago</span></p> <p class="text-gray-800 dark:text-gray-300">Love this post! It really brings back memories.</p> </div> </div> <div class="flex items-start mb-4"> <img src="https://randomuser.me/api/portraits/men/3.jpg" alt="User Avatar" class="rounded-full w-10 h-10 mr-3"> <div class="bg-gray-100 dark:bg-gray-700 p-2 rounded-lg shadow"> <p class="text-brown-800 dark:text-brown-200"><strong>Bob</strong> <span class="text-gray-600 dark:text-gray-400">- 4 hours ago</span></p> <p class="text-gray-800 dark:text-gray-300">The vintage vibe is amazing!</p> </div> </div> </div> </div>
一个响应式的黑暗模式社交登录组件,专为仪表板设计,采用三色方案和丰富的交互元素。它包括各种社交平台的登录选项、用户数据可视化和控制。
<div class="min-h-screen bg-gray-900 text-white flex flex-col items-center justify-center p-6"> <h2 class="text-3xl font-bold mb-6">Login to Your Dashboard</h2> <div class="bg-gray-800 rounded-lg shadow-lg p-8 w-full max-w-sm"> <div class="flex justify-between mb-4"> <span class="text-lg font-semibold">Sign in with:</span> <img src="https://picsum.photos/30/30?random=1" alt="Avatar" class="rounded-full"> </div> <div class="flex flex-col space-y-4"> <a href="#" class="flex items-center justify-center bg-blue-700 text-white font-bold py-2 px-4 rounded hover:bg-blue-600 transition duration-300"> <img class="mr-2" src="https://picsum.photos/30/30?random=2" alt="Facebook" /> Facebook </a> <a href="#" class="flex items-center justify-center bg-green-700 text-white font-bold py-2 px-4 rounded hover:bg-green-600 transition duration-300"> <img class="mr-2" src="https://picsum.photos/30/30?random=3" alt="Google" /> Google </a> <a href="#" class="flex items-center justify-center bg-red-700 text-white font-bold py-2 px-4 rounded hover:bg-red-600 transition duration-300"> <img class="mr-2" src="https://picsum.photos/30/30?random=4" alt="Twitter" /> Twitter </a> </div> <div class="mt-6 text-center"> <span class="text-sm">Don't have an account? <a href="#" class="text-blue-400 hover:underline">Sign up</a></span> </div> </div> <footer class="mt-6 text-gray-400 text-xs"> © 2023 Your Company. All rights reserved. </footer> </div>
一个响应式会话超时警报组件,支持黑暗主题,采用极简/平面美学设计,使用柔和的色彩。它拥有干净的布局,清晰的排版和细微的视觉提示,适合仪表板环境。
<div class="min-h-screen flex items-center justify-center bg-gray-100 dark:bg-gray-900 p-4"> <div class="relative w-full max-w-md bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6"> <!-- Close Button --> <button class="absolute top-4 right-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-200"> <svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /> </svg> </button> <!-- Icon --> <div class="flex justify-center mb-4"> <div class="p-3 bg-yellow-200 dark:bg-yellow-600 rounded-full"> <svg class="h-8 w-8 text-yellow-700 dark:text-yellow-200" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /> </svg> </div> </div> <!-- Title and Description --> <h2 class="text-xl font-semibold text-center text-gray-800 dark:text-white mb-2">Session Timeout</h2> <p class="text-gray-600 dark:text-gray-300 text-center mb-6"> Your session is about to expire. Please save your work and log in again. </p> <!-- Progress Bar (Simulated) --> <div class="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2.5 mb-6"> <div class="bg-pink-400 dark:bg-pink-600 h-2.5 rounded-full" style="width: 75%;"></div> </div> <!-- Action Buttons --> <div class="flex space-x-4"> <button class="flex-1 px-4 py-2 bg-gray-300 dark:bg-gray-600 text-gray-800 dark:text-white rounded-md hover:bg-gray-400 dark:hover:bg-gray-500 transition-colors duration-200"> Save Draft </button> <button class="flex-1 px-4 py-2 bg-purple-400 dark:bg-purple-600 text-white rounded-md hover:bg-purple-500 dark:hover:bg-purple-700 transition-colors duration-200"> Log Out </button> </div> </div> </div>
采用拟物风格设计的搜索框组件,模仿现实世界的搜索框,使用三分色彩方案,适用于作品集,并支持暗模式的响应式设计。
<div class="flex items-center justify-center min-h-screen bg-gray-100 dark:bg-gray-800"> <div class="relative w-full max-w-md"> <input type="text" placeholder="Search..." class="w-full p-4 pl-10 pr-4 text-gray-800 dark:text-gray-200 bg-white dark:bg-gray-900 rounded-lg shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-300 dark:focus:ring-blue-700"/> <div class="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 dark:text-gray-600"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 4a7 7 0 100 14 7 7 0 000-14zM16.293 16.293a8 8 0 111.414-1.414l4.281 4.283-1.414 1.414-4.282-4.283z" /> </svg> </div> </div> </div>