1. Home
  2. /
  3. Metro4
  4. /
  5. Metro 4 Counter Example

Metro 4 Counter Example - Metro4 Typing CST Test

Loading…

Metro 4 Counter Example — Metro4 Code

Demonstrates a simple counter layout using Metro 4 classes and minimal JavaScript for interactivity.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="https://cdn.metroui.org.ua/v4/css/metro-all.min.css">
	<title>Metro 4 Counter</title>
</head>
<body class="m4-container m4-text-center m4-margin-top">
	<h2>Counter: <span id="count">0</span></h2>
	<div class="m4-btn-group">
		<button id="increment" class="m4-btn m4-primary">+</button>
		<button id="decrement" class="m4-btn m4-danger">-</button>
		<button id="reset" class="m4-btn m4-secondary">Reset</button>
	</div>
	<br>
	<button id="theme-btn" class="m4-btn m4-warning">Switch Theme</button>

	<script>
		let count = 0;
		let isDark = false;
		const countEl = document.getElementById('count');
		const body = document.body;

		document.getElementById('increment').onclick = () => { count++; countEl.textContent = count; };
		document.getElementById('decrement').onclick = () => { count--; countEl.textContent = count; };
		document.getElementById('reset').onclick = () => { count = 0; countEl.textContent = count; };
		document.getElementById('theme-btn').onclick = () => {
		isDark = !isDark;
		body.classList.toggle('m4-dark', isDark);
		body.classList.toggle('m4-light', !isDark);
		};
	</script>

	<script src="https://cdn.metroui.org.ua/v4/js/metro.min.js"></script>
</body>
</html>

Metro4 Language Guide

Metro 4 UI is a front-end framework for building responsive, modern web applications with a clean, Windows Metro-inspired design. It provides prebuilt components, responsive grids, and integrated JavaScript widgets.

Primary Use Cases

  • ▸Corporate dashboards and web apps
  • ▸Data-heavy admin panels
  • ▸Prototyping web applications quickly
  • ▸Design systems and reusable UI kits
  • ▸Responsive web applications with rich interactivity

Notable Features

  • ▸Windows Metro-inspired design
  • ▸Responsive grid and layout system
  • ▸Prebuilt UI components (buttons, forms, tables, tiles)
  • ▸Integrated JavaScript widgets
  • ▸Themeable and customizable via LESS/CSS variables

Origin & Creator

Created by Sergey Gulyi in 2015, Metro 4 UI draws inspiration from Microsoft’s Metro design and focuses on modern web apps and dashboards.

Industrial Note

Ideal for building admin dashboards, enterprise web apps, and data-centric interfaces that require structured, ready-made components and widgets.

More Metro4 Typing Exercises

Metro 4 Navbar ExampleMetro 4 Card ExampleMetro 4 Modal ExampleMetro 4 Tabs ExampleMetro 4 Accordion ExampleMetro 4 Slideshow ExampleMetro 4 Tooltip ExampleMetro 4 Progress Bar Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher