Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Basic counter with theme toggle using Tailwind CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<title>Tailwind Counter</title>
</head>
<body class="flex items-center justify-center h-screen bg-gray-100">
<div id="container" class="p-8 bg-white rounded shadow text-center">
<h2 class="text-2xl font-bold mb-4">Counter: <span id="count">0</span></h2>
<div class="flex justify-center gap-2 mb-4">
<button id="increment" class="px-4 py-2 bg-blue-500 text-white rounded">+</button>
<button id="decrement" class="px-4 py-2 bg-red-500 text-white rounded">-</button>
<button id="reset" class="px-4 py-2 bg-gray-500 text-white rounded">Reset</button>
</div>
<button id="theme-btn" class="px-4 py-2 bg-yellow-400 text-black rounded">Switch Theme</button>
</div>
<script>
let count=0,isDark=false;const c=document.getElementById('count'),box=document.getElementById('container');
function update(){c.textContent=count;box.classList.toggle('bg-gray-900',isDark);box.classList.toggle('text-white',isDark);box.classList.toggle('bg-white',!isDark);box.classList.toggle('text-black',!isDark);}
document.getElementById('increment').onclick=()=>{count++;update()};document.getElementById('decrement').onclick=()=>{count--;update()};document.getElementById('reset').onclick=()=>{count=0;update()};document.getElementById('theme-btn').onclick=()=>{isDark=!isDark;update()};update();
</script>
</body>
</html>Tailwind CSS is a utility-first CSS framework that provides low-level, composable classes to build custom designs without writing custom CSS. It emphasizes speed, consistency, and developer productivity.
Origin & Creator
Created by Adam Wathan in 2017 to provide a modern utility-first approach to styling websites and applications, emphasizing rapid development and maintainable styles.
Industrial Note
Tailwind is ideal for teams wanting highly customizable UIs with minimal CSS bloat, and for projects where component-driven design and responsive utilities are priorities.