Stimulus Discourse

Introducing Stimulus-use a collection of composable behaviors

I have just release Stimulus-use a set of composable behaviors to enhance your controllers.

While the initial behaviors have been largely inspired by React-use let’s make it clear that Stimulus-use doesn’t require any React Hooks knowledge :sweat_smile: and is meant to be simple to use :grinning:.

Here is a typical example how you can easily add new lifecycles events to your controllers such as appear, disappear or resize

import { Controller } from 'stimulus'
import { useIntersection, useResize } from 'stimulus-use'

export default class extends Controller {
  connect() {

  appear(entry) {
    // triggered when the element appears within the viewport 
    // and receives an IntersectionObserverEntry object

  resized({ height, width }) {
    // trigered when the element is resized

I plan to had more behaviors in the future but before adding too much I wanted to make sure that the API is suitable. I will welcome all feedback, comments and contributions.

Hopefully as a community we can have a very strong foundation with Stimulus Core and some more agile composable enhancement within a structure such as Stimulus-use or other

Happy Stimulus



Here is an example to create an infinite scroll in a Rails app using the appear function

1 Like