From Hotwire to Optimistic UI: Harnessing Custom Elements in Rails
Custom elements—once a niche part of the Web Components spec—are now a practical tool for Rails developers. By pairing them with Hotwire’s Turbo, you can build reusable, instantly‑responsive UI pieces without sacrificing semantic HTML or server‑side rendering. This article walks through the fundamentals, contrasts them with Stimulus, and shows a real‑world optimistic‑form pattern that keeps users engaged while the server catches up.