Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple counter layout using Materialize 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 href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet">
<title>Materialize Counter</title>
</head>
<body class="container center-align">
<h2>Counter: <span id="count">0</span></h2>
<div class="btn-group">
<a id="increment" class="btn blue">+</a>
<a id="decrement" class="btn red">-</a>
<a id="reset" class="btn grey">Reset</a>
</div>
<br><br>
<a id="theme-btn" class="btn yellow darken-2">Switch Theme</a>
<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('black', isDark);
body.classList.toggle('white', !isDark);
body.classList.toggle('white-text', isDark);
body.classList.toggle('black-text', !isDark);
};
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
</html>Materialize is a modern, responsive front-end CSS framework based on Google's Material Design guidelines. It provides prebuilt components, responsive grids, and JavaScript plugins to build web interfaces quickly.
Origin & Creator
Developed by a community-led initiative inspired by Google’s Material Design, first released in 2014.
Industrial Note
Materialize is popular in educational projects, prototyping, and apps where a Material Design aesthetic is preferred, including dashboards and web apps.