stimulus-controllers
Installation
SKILL.md
Stimulus Controllers
Implement lightweight, composable Stimulus controllers that enhance server-rendered HTML without reinventing a client-side framework.
Core Workflow
Step 1: Define the Controller Contract
Before writing code, declare the full public surface:
| Element | Purpose | Declaration |
|---|---|---|
| Targets | DOM elements the controller reads or mutates | static targets = ["name"] |
| Values | Reactive state with type checking and defaults | static values = { open: Boolean } |
| Outlets | References to other controllers on the page | static outlets = ["other-controller"] |
| Actions | Controller methods wired from HTML | data-action="click->controller#method" |
| CSS Classes | Logical class names mapped to real CSS classes | static classes = ["active"] |
Declare targets, values, outlets, and CSS classes in static properties. Actions are ordinary controller methods referenced by HTML descriptors.