stimulus
SKILL.md
Stimulus Best Practices for Rails Applications
Rule updated on 12/15/2025 to Stimulus version 3.2.2
Stimulus is a modest JavaScript framework designed to augment your HTML with just enough behavior. It connects JavaScript to the DOM via data attributes, keeping your HTML as the source of truth.
For full reference see https://stimulus.hotwired.dev/
Core Concepts
| Concept | Purpose | Data Attribute |
|---|---|---|
| Controller | JavaScript class that adds behavior | data-controller="name" |
| Target | Important elements referenced in JS | data-name-target="targetName" |
| Action | Event handlers connecting DOM to methods | data-action="event->name#method" |
| Value | Reactive data stored in HTML | data-name-value-name="value" |
| Class | CSS classes toggled by the controller | data-name-class-name="class" |
| Outlet | References to other controllers | data-name-outlet-name="selector" |