浏览所有可用的 Tailwind CSS 组件
使用 Tailwind CSS 的简单画廊组件,使用三色方案实现粗野主义设计风格,并支持深色主题来展示作品或产品。
<div class="bg-gray-800 dark:bg-gray-900 p-6"> <h1 class="text-4xl font-bold text-green-400 mb-4">Gallery</h1> <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4"> <div class="bg-gray-700 dark:bg-gray-800 rounded-lg overflow-hidden shadow-lg"> <img src="https://picsum.photos/400/300?random=1" alt="Gallery Image 1" class="w-full h-32 object-cover"> <div class="p-4"> <h2 class="text-xl font-bold text-pink-400">Project Title 1</h2> <p class="text-gray-300 dark:text-gray-400">Short description of the project showcasing its highlights.</p> <div class="mt-2"> <img src="https://randomuser.me/api/portraits/men/1.jpg" alt="User Avatar" class="w-10 h-10 rounded-full inline-block"> <span class="text-gray-200 dark:text-gray-300 ml-2">Author Name</span> </div> </div> </div> <div class="bg-gray-700 dark:bg-gray-800 rounded-lg overflow-hidden shadow-lg"> <img src="https://picsum.photos/400/300?random=2" alt="Gallery Image 2" class="w-full h-32 object-cover"> <div class="p-4"> <h2 class="text-xl font-bold text-pink-400">Project Title 2</h2> <p class="text-gray-300 dark:text-gray-400">Short description of the project showcasing its highlights.</p> <div class="mt-2"> <img src="https://randomuser.me/api/portraits/women/1.jpg" alt="User Avatar" class="w-10 h-10 rounded-full inline-block"> <span class="text-gray-200 dark:text-gray-300 ml-2">Author Name</span> </div> </div> </div> <div class="bg-gray-700 dark:bg-gray-800 rounded-lg overflow-hidden shadow-lg"> <img src="https://picsum.photos/400/300?random=3" alt="Gallery Image 3" class="w-full h-32 object-cover"> <div class="p-4"> <h2 class="text-xl font-bold text-pink-400">Project Title 3</h2> <p class="text-gray-300 dark:text-gray-400">Short description of the project showcasing its highlights.</p> <div class="mt-2"> <img src="https://randomuser.me/api/portraits/men/2.jpg" alt="User Avatar" class="w-10 h-10 rounded-full inline-block"> <span class="text-gray-200 dark:text-gray-300 ml-2">Author Name</span> </div> </div> </div> <div class="bg-gray-700 dark:bg-gray-800 rounded-lg overflow-hidden shadow-lg"> <img src="https://picsum.photos/400/300?random=4" alt="Gallery Image 4" class="w-full h-32 object-cover"> <div class="p-4"> <h2 class="text-xl font-bold text-pink-400">Project Title 4</h2> <p class="text-gray-300 dark:text-gray-400">Short description of the project showcasing its highlights.</p> <div class="mt-2"> <img src="https://randomuser.me/api/portraits/women/2.jpg" alt="User Avatar" class="w-10 h-10 rounded-full inline-block"> <span class="text-gray-200 dark:text-gray-300 ml-2">Author Name</span> </div> </div> </div> </div> </div>
响应式时间轴组件,具有 glassmorphism 样式和三色配色方案。它包括具有模糊效果的磨砂玻璃状半透明元素,适用于博客和内容消费,并支持深色模式。
<div class="bg-gray-50 dark:bg-gray-900 flex justify-center py-10"> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 max-w-xl w-full backdrop-blur-md bg-opacity-30 border border-gray-200 dark:border-gray-700"> <h2 class="text-2xl font-bold text-center text-gray-800 dark:text-gray-100 mb-6">Timeline</h2> <div class="relative mb-4"> <div class="flex justify-between items-center mb-4"> <div class="w-1/2 flex items-center"> <div class="h-8 w-8 rounded-full overflow-hidden shadow-lg"> <img src="https://picsum.photos/40/40" alt="" class="object-cover"> </div> <div class="ml-4"> <p class="text-sm text-gray-600 dark:text-gray-400">Event 1</p> <p class="text-xs text-gray-500 dark:text-gray-500">Date 1</p> </div> </div> <div class="h-1 w-1 bg-gray-300 dark:bg-gray-700"></div> <div class="w-1/2 text-right"> <p class="text-sm text-gray-600 dark:text-gray-400">Description of Event 1.</p> </div> </div> </div> <div class="relative mb-4"> <div class="flex justify-between items-center mb-4"> <div class="w-1/2 flex items-center"> <div class="h-8 w-8 rounded-full overflow-hidden shadow-lg"> <img src="https://picsum.photos/40/40" alt="" class="object-cover"> </div> <div class="ml-4"> <p class="text-sm text-gray-600 dark:text-gray-400">Event 2</p> <p class="text-xs text-gray-500 dark:text-gray-500">Date 2</p> </div> </div> <div class="h-1 w-1 bg-gray-300 dark:bg-gray-700"></div> <div class="w-1/2 text-right"> <p class="text-sm text-gray-600 dark:text-gray-400">Description of Event 2.</p> </div> </div> </div> <div class="relative mb-4"> <div class="flex justify-between items-center mb-4"> <div class="w-1/2 flex items-center"> <div class="h-8 w-8 rounded-full overflow-hidden shadow-lg"> <img src="https://picsum.photos/40/40" alt="" class="object-cover"> </div> <div class="ml-4"> <p class="text-sm text-gray-600 dark:text-gray-400">Event 3</p> <p class="text-xs text-gray-500 dark:text-gray-500">Date 3</p> </div> </div> <div class="h-1 w-1 bg-gray-300 dark:bg-gray-700"></div> <div class="w-1/2 text-right"> <p class="text-sm text-gray-600 dark:text-gray-400">Description of Event 3.</p> </div> </div> </div> </div> </div>
一个响应式下拉菜单组件,采用 glassmorphism 样式,适合博客或内容消费,支持深色主题。
<div class="relative inline-block text-left"> <div> <button type="button" class="flex items-center justify-between w-full rounded-md border border-transparent bg-white bg-opacity-30 dark:bg-gray-800 dark:bg-opacity-50 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-opacity-40 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2" aria-haspopup="true" aria-expanded="true" aria-controls="dropdown-menu"> Menu <svg class="w-5 h-5 ml-2 -mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 011.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" /> </svg> </button> </div> <div class="hidden z-10 mt-2 w-56 rounded-md shadow-lg bg-white bg-opacity-30 dark:bg-gray-800 dark:bg-opacity-50 ring-1 ring-black ring-opacity-5" id="dropdown-menu" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1"> <div class="py-1" role="none"> <a href="#" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-700" role="menuitem">Profile</a> <a href="#" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-700" role="menuitem">Settings</a> <a href="#" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-700" role="menuitem">Sign out</a> </div> </div> </div> <div class="mt-8 flex items-center justify-center"> <div class="relative w-16 h-16 rounded-full overflow-hidden bg-white bg-opacity-30 dark:bg-gray-800 dark:bg-opacity-50"> <img src="https://picsum.photos/seed/picsum/200/200" alt="Random" class="object-cover w-full h-full rounded-full"> </div> </div>
响应式 Toast 通知组件,具有 Glassmorphism 风格,适用于商业/公司网站,支持深色主题。柔和的配色方案。
<div class="fixed bottom-5 right-5 space-y-4 z-50"> <!-- Success Toast --> <div class="bg-white bg-opacity-30 backdrop-filter backdrop-blur-lg rounded-lg shadow-lg p-4 pr-10 max-w-sm mx-auto dark:bg-gray-800 dark:bg-opacity-30"> <div class="flex items-center space-x-3"> <div class="flex-shrink-0"> <svg class="h-6 w-6 text-green-500" 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="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> </div> <div class="flex-1"> <p class="text-sm font-medium text-gray-900 dark:text-white">Success Message</p> <p class="mt-1 text-sm text-gray-500 dark:text-gray-300">Your action was successful.</p> </div> </div> </div> <!-- Info Toast --> <div class="bg-white bg-opacity-30 backdrop-filter backdrop-blur-lg rounded-lg shadow-lg p-4 pr-10 max-w-sm mx-auto dark:bg-gray-800 dark:bg-opacity-30"> <div class="flex items-center space-x-3"> <div class="flex-shrink-0"> <svg class="h-6 w-6 text-blue-500" 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 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> </div> <div class="flex-1"> <p class="text-sm font-medium text-gray-900 dark:text-white">Information</p> <p class="mt-1 text-sm text-gray-500 dark:text-gray-300">This is an informational message.</p> </div> </div> </div> <!-- Warning Toast --> <div class="bg-white bg-opacity-30 backdrop-filter backdrop-blur-lg rounded-lg shadow-lg p-4 pr-10 max-w-sm mx-auto dark:bg-gray-800 dark:bg-opacity-30"> <div class="flex items-center space-x-3"> <div class="flex-shrink-0"> <svg class="h-6 w-6 text-yellow-500" 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 9v2m0 4h.01m-6.938 4H21a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg> </div> <div class="flex-1"> <p class="text-sm font-medium text-gray-900 dark:text-white">Warning</p> <p class="mt-1 text-sm text-gray-500 dark:text-gray-300">Something might be wrong.</p> </div> </div> </div> <!-- Error Toast --> <div class="bg-white bg-opacity-30 backdrop-filter backdrop-blur-lg rounded-lg shadow-lg p-4 pr-10 max-w-sm mx-auto dark:bg-gray-800 dark:bg-opacity-30"> <div class="flex items-center space-x-3"> <div class="flex-shrink-0"> <svg class="h-6 w-6 text-red-500" 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="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> </div> <div class="flex-1"> <p class="text-sm font-medium text-gray-900 dark:text-white">Error</p> <p class="mt-1 text-sm text-gray-500 dark:text-gray-300">An error occurred.</p> </div> </div> </div> </div>
用于社交媒体的简单单色复古主题布局,支持深色模式。
<div class="min-h-screen bg-gray-100 dark:bg-gray-900 py-8"> <div class="container mx-auto px-4"> <div class="flex flex-col md:flex-row gap-8"> <!-- Left Sidebar --> <div class="md:w-1/4"> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6"> <h2 class="text-lg font-bold text-gray-800 dark:text-white mb-4">Profile</h2> <div class="flex items-center mb-4"> <img class="w-12 h-12 rounded-full mr-4" src="https://randomuser.me/api/portraits/men/1.jpg" alt="Avatar"> <div> <p class="font-semibold text-gray-800 dark:text-white">John Doe</p> <p class="text-sm text-gray-600 dark:text-gray-400">View Profile</p> </div> </div> <ul class="space-y-2"> <li><a href="#" class="text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white text-sm">Feed</a></li> <li><a href="#" class="text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white text-sm">Messages</a></li> <li><a href="#" class="text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white text-sm">Settings</a></li> </ul> </div> </div> <!-- Main Content --> <div class="md:w-1/2"> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6"> <h2 class="text-lg font-bold text-gray-800 dark:text-white mb-4">Posts</h2> <div class="border-b border-gray-200 dark:border-gray-700 mb-6 pb-6"> <div class="flex items-center mb-4"> <img class="w-10 h-10 rounded-full mr-4" src="https://randomuser.me/api/portraits/women/2.jpg" alt="Avatar"> <div> <p class="font-semibold text-gray-800 dark:text-white">Jane Smith</p> <p class="text-sm text-gray-600 dark:text-gray-400">2 hours ago</p> </div> </div> <p class="text-gray-700 dark:text-gray-300 mb-4">This is an example post with some sample text. #retro #coding</p> <img class="w-full rounded-lg" src="https://picsum.photos/seed/retro1/600/400" alt="Post Image"> </div> <div class="border-b border-gray-200 dark:border-gray-700 mb-6 pb-6"> <div class="flex items-center mb-4"> <img class="w-10 h-10 rounded-full mr-4" src="https://randomuser.me/api/portraits/men/3.jpg" alt="Avatar"> <div> <p class="font-semibold text-gray-800 dark:text-white">Peter Jones</p> <p class="text-sm text-gray-600 dark:text-gray-400">5 hours ago</p> </div> </div> <p class="text-gray-700 dark:text-gray-300 mb-4">Another post example. Simple is often better. #monochromatic</p> <img class="w-full rounded-lg" src="https://picsum.photos/seed/retro2/600/400" alt="Post Image"> </div> </div> </div> <!-- Right Sidebar --> <div class="md:w-1/4"> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6"> <h2 class="text-lg font-bold text-gray-800 dark:text-white mb-4">Suggestions</h2> <ul class="space-y-4"> <li class="flex items-center"> <img class="w-10 h-10 rounded-full mr-4" src="https://randomuser.me/api/portraits/women/4.jpg" alt="Avatar"> <div> <p class="font-semibold text-gray-800 dark:text-white">Sara White</p> <p class="text-sm text-gray-600 dark:text-gray-400">Follow</p> </div> </li> <li class="flex items-center"> <img class="w-10 h-10 rounded-full mr-4" src="https://randomuser.me/api/portraits/men/5.jpg" alt="Avatar"> <div> <p class="font-semibold text-gray-800 dark:text-white">David Green</p> <p class="text-sm text-gray-600 dark:text-gray-400">Follow</p> </div> </li> </ul> </div> </div> </div> </div> </div>
一个简单的产品比较组件,专为使用灰度配色方案的深色模式 UI 而设计。它具有元素最少的基本布局,非常适合博客内容和阅读目的。
<div class="bg-gray-800 text-white p-4 rounded-lg shadow-lg max-w-2xl mx-auto"> <h2 class="text-xl font-bold mb-4">Product Comparison</h2> <table class="min-w-full"> <thead> <tr class="bg-gray-700"> <th class="px-4 py-2">Feature</th> <th class="px-4 py-2">Product A</th> <th class="px-4 py-2">Product B</th> </tr> </thead> <tbody> <tr class="border-b border-gray-600"> <td class="px-4 py-2">Price</td> <td class="px-4 py-2">$199</td> <td class="px-4 py-2">$249</td> </tr> <tr class="border-b border-gray-600"> <td class="px-4 py-2">Rating</td> <td class="px-4 py-2">⭐⭐⭐⭐</td> <td class="px-4 py-2">⭐⭐⭐⭐⭐</td> </tr> <tr class="border-b border-gray-600"> <td class="px-4 py-2">Warranty</td> <td class="px-4 py-2">1 Year</td> <td class="px-4 py-2">2 Years</td> </tr> <tr class="border-b border-gray-600"> <td class="px-4 py-2">Image</td> <td class="px-4 py-2"><img src="https://picsum.photos/100/100?random=1" alt="Product A" class="rounded" /></td> <td class="px-4 py-2"><img src="https://picsum.photos/100/100?random=2" alt="Product B" class="rounded" /></td> </tr> </tbody> </table> <div class="flex justify-between mt-4"> <div class="flex items-center"> <img src="https://randomuser.me/api/portraits/men/1.jpg" alt="User Avatar" class="w-10 h-10 rounded-full" /> <span class="ml-2">Reviewed by John Doe</span> </div> <a href="#" class="text-blue-400 hover:underline">Read More</a> </div> </div>
一个响应式选项卡组件,以拟物化风格为电子商务应用程序设计,使用柔和的配色方案和 Tailwind CSS。
<div class="max-w-3xl mx-auto p-4"> <h2 class="text-2xl font-semibold mb-4">Product Categories</h2> <div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-300 dark:border-gray-700"> <div class="flex border-b border-gray-200 dark:border-gray-600"> <button class="flex-1 py-3 text-center text-gray-700 dark:text-gray-200 font-semibold rounded-t-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400"> <span>Electronics</span> </button> <button class="flex-1 py-3 text-center text-gray-700 dark:text-gray-200 font-semibold rounded-t-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400"> <span>Clothing</span> </button> <button class="flex-1 py-3 text-center text-gray-700 dark:text-gray-200 font-semibold rounded-t-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400"> <span>Home & Kitchen</span> </button> </div> <div class="p-4"> <div class="tab-content hidden"> <h3 class="text-xl font-semibold">Electronics</h3> <img src="https://picsum.photos/300/200?random=1" alt="Electronics" class="rounded-lg mb-4"> <p class="text-gray-600 dark:text-gray-400">Latest gadgets and devices for your tech needs.</p> </div> <div class="tab-content hidden"> <h3 class="text-xl font-semibold">Clothing</h3> <img src="https://picsum.photos/300/200?random=2" alt="Clothing" class="rounded-lg mb-4"> <p class="text-gray-600 dark:text-gray-400">Trendy and comfortable apparel for all occasions.</p> </div> <div class="tab-content hidden"> <h3 class="text-xl font-semibold">Home & Kitchen</h3> <img src="https://picsum.photos/300/200?random=3" alt="Home & Kitchen" class="rounded-lg mb-4"> <p class="text-gray-600 dark:text-gray-400">Quality products to enhance your living spaces.</p> </div> </div> </div> </div>
一个响应式目录组件,以 Material Design 风格设计,具有大地色调和深色主题支持,适用于商业/公司网站。
<div class="bg-white dark:bg-gray-800 shadow-lg rounded-lg p-6"> <h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Table of Contents</h2> <ul class="mt-4 space-y-2"> <li class="flex items-center"> <img src="https://i.pravatar.cc/40" alt="Avatar" class="w-10 h-10 rounded-full mr-3"> <a href="#section1" class="text-gray-700 dark:text-gray-300 hover:underline">Section 1</a> </li> <li class="flex items-center"> <img src="https://i.pravatar.cc/41" alt="Avatar" class="w-10 h-10 rounded-full mr-3"> <a href="#section2" class="text-gray-700 dark:text-gray-300 hover:underline">Section 2</a> </li> <li class="flex items-center"> <img src="https://i.pravatar.cc/42" alt="Avatar" class="w-10 h-10 rounded-full mr-3"> <a href="#section3" class="text-gray-700 dark:text-gray-300 hover:underline">Section 3</a> </li> <li class="flex items-center"> <img src="https://i.pravatar.cc/43" alt="Avatar" class="w-10 h-10 rounded-full mr-3"> <a href="#section4" class="text-gray-700 dark:text-gray-300 hover:underline">Section 4</a> </li> </ul> </div> <div class="bg-gray-200 dark:bg-gray-900 p-6 mt-6 rounded-lg"> <h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Additional Resources</h3> <ul class="mt-2 space-y-1"> <li> <a href="#resource1" class="text-gray-600 dark:text-gray-400 hover:underline">Resource 1</a> </li> <li> <a href="#resource2" class="text-gray-600 dark:text-gray-400 hover:underline">Resource 2</a> </li> <li> <a href="#resource3" class="text-gray-600 dark:text-gray-400 hover:underline">Resource 3</a> </li> </ul> </div>
一个 Neumorphism 样式的标题组件,用于具有深色主题、响应式设计并包含多个交互式元素的投资组合。
<header class="bg-gray-100 dark:bg-gray-800 shadow-lg rounded-lg p-6 flex flex-col md:flex-row items-center justify-between space-y-4 md:space-y-0"> <div class="flex items-center space-x-4"> <img src="https://picsum.photos/60" alt="Logo" class="h-10 w-10 rounded-full shadow-lg"> <h1 class="text-2xl font-bold text-gray-900 dark:text-white">My Portfolio</h1> </div> <nav class="flex space-x-4"> <a href="#" class="text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition duration-200">Home</a> <a href="#" class="text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition duration-200">About</a> <a href="#" class="text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition duration-200">Projects</a> <a href="#" class="text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition duration-200">Contact</a> </nav> <div class="flex items-center space-x-2"> <img src="https://randomuser.me/api/portraits/men/1.jpg" alt="User Avatar" class="h-10 w-10 rounded-full shadow-lg"> <button class="bg-blue-500 dark:bg-blue-700 text-white font-semibold py-2 px-4 rounded-lg transition duration-200 hover:bg-blue-600 dark:hover:bg-blue-800">Get In Touch</button> </div> </header>
专为博客设计的极简警报消息组件,具有灰度配色方案。它包括标题、消息和关闭按钮。支持深色主题的响应式设计。
<div class="flex flex-col items-center justify-center p-4 bg-white dark:bg-gray-900 rounded-md shadow-lg max-w-md mx-auto mt-6"> <div class="flex justify-between items-center w-full"> <h2 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Alert Title</h2> <button class="text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none"> × </button> </div> <p class="mt-2 text-gray-600 dark:text-gray-400"> This is a minimal alert message for your blog or content. It is meant to grab the reader's attention without being intrusive. </p> <div class="flex items-center mt-3"> <img src="https://randomuser.me/api/portraits/men/1.jpg" alt="User" class="w-8 h-8 rounded-full mr-2"> <span class="text-gray-700 dark:text-gray-300 text-sm">Posted by John Doe</span> </div> <div class="flex justify-end mt-4"> <button class="px-4 py-2 bg-gray-800 text-white rounded-md hover:bg-gray-700 dark:bg-gray-600 dark:hover:bg-gray-500"> Action </button> </div> </div>