Svelte Custom Elements Demo

Interactive calculator tools demonstrating Svelte 5 custom elements with reactive state

For software application and development services, contact me via https://appsoftware.com

This application uses Svelte 5 Custom Elements to build reusable, interactive components that integrate seamlessly with server-rendered ASP.NET MVC pages. By compiling Svelte components as Web Components (browser-native custom elements), we achieve clean encapsulation of logic and state while maintaining standards compliance and framework independence. These calculators demonstrate the approach: each component manages its own reactive state using Svelte's modern Runes syntax, automatically updating the UI when values change—all without manual DOM manipulation or event wiring. The components work alongside Alpine.js and vanilla JavaScript without conflicts, can be styled with page-level CSS (via shadow: "none"), and require only a simple <script> tag to function. This pattern enables progressive enhancement of existing pages with sophisticated interactivity while keeping the codebase maintainable and the architecture flexible.

An example of a more comprehensive tool built as a Svelte 5 custom element can be seen in our Values and Grid Art Tool page.

Add

Multiply

These components are:

  • Built with Svelte 5 using modern Runes syntax ($state, $derived)
  • Compiled as Custom Elements (Web Components) for framework-agnostic integration
  • Uses shadow: "none" to allow Bulma CSS styling from the parent page
  • Bundled in forms.iife.js alongside other form-based utility components
  • Demonstrates reactive computed values without manual event handling