All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Building Optimistic UI with Custom Elements in Rails

By

amalinovic

5mo ago· 6 min readen

Summary

This article explains how to use custom elements in Rails to build optimistic UI interfaces. It covers what custom elements are, how they compare to Stimulus controllers, and provides practical examples from building a simple counter to creating an optimistic form that updates instantly without waiting for server responses. The article demonstrates that custom elements are simpler than they sound, noting that Rails developers using Hotwire have already worked with them through <turbo-frame> and <turbo-stream> tags.

Key quotes

· 5 pulled
Custom elements are one of those web platform features that sound complicated but turn out to be surprisingly simple.
Both <turbo-frame> and <turbo-stream> are custom elements. They are just HTML tags with JavaScript behavior attached.
Starting with a simple counter and ending with an optimistic form that updates instantly without waiting for the server.
Learn how custom elements work in Rails by building an optimistic form.
Understand when to use custom elements over Stimulus controllers.
Snippet from the RSS feed
Learn how custom elements work in Rails by building an optimistic form. From simple counters to instant UI updates, understand when to use custom elements over Stimulus controllers.

You might also wanna read