1. Home
  2. /
  3. Tailwind-css
  4. /
  5. Tailwind CSS Simple Counter

Tailwind CSS Simple Counter - Tailwind-css Typing CST Test

Loading…

Tailwind CSS Simple Counter — Tailwind-css Code

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 Language Guide

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.

Primary Use Cases

  • ▸Modern web applications
  • ▸Design systems and component libraries
  • ▸Rapid prototyping
  • ▸Landing pages and marketing websites
  • ▸Custom dashboards and admin panels

Notable Features

  • ▸Utility-first atomic classes
  • ▸Responsive and state variants
  • ▸Highly customizable via config
  • ▸PurgeCSS integration for minimal CSS
  • ▸Built-in dark mode support

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.

More Tailwind-css Typing Exercises

Tailwind CSS Counter with StepTailwind CSS Counter with Min/MaxTailwind CSS Auto Increment CounterTailwind CSS Counter with Double IncrementTailwind CSS Counter with Even/Odd IndicatorTailwind CSS Counter with LocalStorageTailwind CSS Counter with Color ThemesTailwind CSS Animated CounterTailwind CSS Counter with Progress Bar

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher