1. Home
  2. /
  3. Riot-js
  4. /
  5. Riot.js Counter Component

Riot.js Counter Component - Riot-js Typing CST Test

Loading…

Riot.js Counter Component — Riot-js Code

Basic Riot.js counter with dark/light theme toggle.

<counter>
	<h2>Counter: {state.count}</h2>
	<div>
		<button onclick={() => state.count++}>+</button>
		<button onclick={() => state.count--}>-</button>
		<button onclick={() => state.count = 0}>Reset</button>
	</div>
	<button onclick={() => state.isDark = !state.isDark}>Switch to {state.isDark ? 'Light' : 'Dark'} Theme</button>

	<script>
		export default {
		state: { count: 0, isDark: false }
		}
	</script>
</counter>

<script type="module">
	import { component } from 'riot';
	import Counter from './counter.riot';
	component(Counter)(document.body);
</script>
<style>
	.dark-theme { background-color: #222; color: #eee; }
	.light-theme { background-color: #fff; color: #000; }
</style>

Riot-js Language Guide

Riot.js is a lightweight, client-side JavaScript framework for building web applications with a component-based architecture. It combines simple syntax, a virtual DOM, and reactive data binding to create maintainable, modular UI components.

Primary Use Cases

  • ▸Single-page applications
  • ▸Component libraries
  • ▸Dashboards and admin panels
  • ▸Interactive UI widgets
  • ▸Rapid prototyping with clean, modular code

Notable Features

  • ▸Small and lightweight (~10 KB gzipped)
  • ▸Component-based design
  • ▸Virtual DOM for efficient rendering
  • ▸Reactive state management
  • ▸Simple, declarative syntax

Origin & Creator

Created by Muut and first released in 2014.

Industrial Note

Riot.js is ideal for developers seeking minimalistic, performant frameworks for modular web apps without the overhead of larger frameworks like React or Angular.

More Riot-js Typing Exercises

Riot.js Counter with Step IncrementRiot.js Counter with Max LimitRiot.js Counter with Auto-ResetRiot.js Counter with HistoryRiot.js Counter with Dark Mode OnlyRiot.js Counter with Auto-IncrementRiot.js Counter with Conditional ThemeRiot.js Full Featured Counter

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher