Gathering detailed insights and metrics for stimulus-use
Gathering detailed insights and metrics for stimulus-use
Gathering detailed insights and metrics for stimulus-use
Gathering detailed insights and metrics for stimulus-use
stimulus-use-tinygesture
Tracks the user's gesture on an element using the tinygesture library.
stimulus-use-actions
Stimulus mixin for declaring actions in the controller
@lysyi3m/stimulus-use-validation
Lightweight, zero dependency, customizable mixin for Stimulus to handle form validation easily. Heavily rely on Constraint Validation API with support for custom validators.
@mguidetti/stimulus-components
[Stimulus](https://github.com/hotwired/stimulus) components used in my projects. Free to use and contributions welcome.
A collection of composable behaviors for your Stimulus Controllers
npm install stimulus-use
Typescript
Module System
JavaScript (41.45%)
TypeScript (33.89%)
HTML (24.64%)
CSS (0.03%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,629 Stars
685 Commits
70 Forks
14 Watchers
17 Branches
38 Contributors
Updated on Jul 09, 2025
Latest Version
0.52.3
Package Id
stimulus-use@0.52.3
Unpacked Size
166.84 kB
Size
31.25 kB
File Count
91
Published on
Dec 15, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
43
If you want to use stimulus-use
with Stimulus 3 you can use the version 0.50.0+
. This and all future versions are designed to work with the @hotwired/stimulus
npm package.
Note: If other packages still depend on the stimulus
npm package you can safely keep that in your package.json
, this won't break the stimulus-use
compability.
1npm i stimulus-use @hotwired/stimulus
1yarn add stimulus-use @hotwired/stimulus
If you want to use stimulus-use
with Stimulus 2 (or below) you can use version 0.41.0
. This version is designed to work with the stimulus
npm package.
1npm i stimulus-use@0.41.0 stimulus@2.0.0
1yarn add stimulus-use@0.41.0 stimulus@2.0.0
We got you covered 👉 stimulus-use.github.io/stimulus-use
This set of mixins is built around the Observer APIs
and custom events to enhance your controllers with new behaviors.
Mixin | Description | NEW Callbacks |
---|---|---|
useClickOutside | Tracks the clicks outside of the element and adds a new lifecycle callback clickOutside. | clickOutside |
useHotkeys | Registers hotkeys using the hotkeys-js library and binds them to handler methods | |
useHover | Tracks the user's mouse movements over an element and adds mouseEnter and mouseLeave callbacks to your controller. | mouseEnter mouseLeave |
useIdle | Tracks if the user is idle on your page and adds away and back callbacks to your controller. | away back |
useIntersection | Tracks the element's intersection and adds appear, disappear callbacks to your controller. | appear disappear |
useMatchMedia | Tracks if the window matches a media query string. | is[Name] , not[Name] and [name]Changed |
useMutation | Tracks mutations on an element, its attributes and/or subtree. Adds a mutate callback to your controller. | mutate |
useResize | Tracks the element's size and adds a new lifecycle callback resize. | resize |
useTargetMutation | Tracks when targets are added or removed from the controller's scope, or their contents changed. Adds [target]TargetAdded , [target]TargetRemoved and [target]TargetChanged callback to your controller for each specified target. | [target]TargetAdded [target]TargetRemoved [target]TargetChanged |
useVisibility | Tracks the page visibility and adds visible, invisible callbacks to your controller. | visible invisible |
useWindowFocus | Tracks the window focus and adds focus, unfocus callbacks to your controller. | focus unfocus |
useWindowResize | Tracks the size of the window object and adds a new lifecycle callback windowResize. | windowResize |
A set of mixin to optimize performances.
Mixin | Description |
---|---|
useDebounce | Adds the ability to specify an array "debounces" of functions to debounce. |
useMemo | Memoize expensive getters by mixing in useMemo and adding a static memos array. |
useThrottle | Adds the ability to specify an array "throttles" of functions to throttle. |
A set of mixin and controllers to build animations.
Mixin | Description |
---|---|
useTransition | Mixin or controller to apply classes to various stages of an element's transition. |
Mixin | Description |
---|---|
useApplication, ApplicationController | supercharged controller for your application. |
useDispatch | Adds a dispatch helper function to emit custom events. Useful to communicate between different controllers. |
useMeta | Adds getters to easily access meta values. |
Stimulus-use can be used in two ways: composing with mixins or extending built-in controllers
Composing with mixins
This is the prefered approach as it bring the most flexibility. Simply import a mixin and apply it in the connect
or initialize
to adds new behaviors to you controller. You can combine several mixins within the same controller.
1import { Controller } from '@hotwired/stimulus' 2import { useIntersection, useResize } from 'stimulus-use' 3 4export default class extends Controller { 5 connect() { 6 useIntersection(this) 7 useResize(this) 8 } 9 10 appear(entry) { 11 // triggered when the element appears within the viewport 12 } 13 14 resize({ height, width }) { 15 // trigered when the element is resized 16 } 17}
Extending built-in controllers
You can create your Stimulus controller from a pre-built Stimulus-use controller which offers the new behavior you're looking for. This method works perfectly when you only need a single behavior for your controller.
1import { IntersectionController } from 'stimulus-use' 2 3export default class extends IntersectionController { 4 appear(entry) { 5 // triggered when the element appears within the viewport 6 } 7}
yarn install
yarn start
- to run the local dev server with examplesyarn test
- to run the unit testsyarn lint
- to run the linter with ESLintyarn format
- to format changes with Prettieryarn build
- to bundle the app into static files for productionMade with :heart: by @adrienpoly, @marcoroth and all these wonderful contributors (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Continuous integration and cross browser testing is generously provided Sauce Labs.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 8
Details
Reason
Found 4/7 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More