Registry / web-framework / vue-ripple-directive

vue-ripple-directive

JSON →
library2.0.1jsnpmunverified

vue-ripple-directive is a lightweight Vue.js directive that implements the Material Design ripple effect on any HTML element. Currently stable at version 2.0.1, the package provides a focused solution for adding interactive visual feedback to user interface elements, differentiating itself from larger component libraries by offering only the ripple functionality. Releases have historically addressed bug fixes and introduced features like custom colors and event modifiers, though recent development pace appears moderate. A key characteristic is its reliance on the host element having `position: relative` for accurate ripple positioning, a behavior that was explicitly enforced as a breaking change in version 2.0.1. It can be configured globally for default colors and z-index.

npm install vue-ripple-directive
INSTALL
IMPORT
SIG · VUE-RIPPLE-DIRECTI
V
vue-ripple-directive
web-frameworkjavascriptv2.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Ripple
✓ import Ripple from 'vue-ripple-directive';
✗ const Ripple = require('vue-ripple-directive');
For Vue 3, register globally using `app.directive('ripple', Ripple)`. For Vue 2, use `Vue.directive('ripple', Ripple)`.

This quickstart demonstrates how to import, globally configure, and register the `v-ripple` directive in a Vue 3 application. It then shows its usage in a template with default behavior, a custom color parameter, and event/transition modifiers, emphasizing the essential `position: relative` CSS requirement.

import { createApp } from 'vue'; import App from './App.vue'; import Ripple from 'vue-ripple-directive'; const app = createApp(App); // Optional: Global configuration for all ripples Ripple.color = 'rgba(100, 100, 255, 0.3)'; // Default blueish ripple color Ripple.zIndex = 999; // Default z-index for ripple elements // Register the directive globally app.directive('ripple', Ripple); app.mount('#app'); /* In App.vue or any Vue component template: */ /* <template> <div id="app"> <h2>Click for a ripple effect!</h2> <div v-ripple class="my-button default-ripple"> Default Ripple </div> <div v-ripple="'rgba(255, 0, 0, 0.4)'" class="my-button red-ripple"> Red Ripple (Custom Color) </div> <div v-ripple.mouseover.1000 class="my-button hover-ripple"> Hover Ripple (Custom Event & Speed) </div> <p> This paragraph also has a ripple, but it might not look right if its position is not relative! <span v-ripple class="inline-ripple">Click here</span> </p> </div> </template> <script> export default { name: 'App', }; </script> <style> /* CRUCIAL: Elements with v-ripple MUST have position: relative */ .my-button, .inline-ripple { position: relative; overflow: hidden; /* Ensures the ripple is clipped within bounds */ background-color: #4CAF50; color: white; padding: 15px 30px; margin: 10px; border-radius: 5px; cursor: pointer; display: inline-block; } .red-ripple { background-color: #f44336; } .hover-ripple { background-color: #2196F3; } .inline-ripple { background-color: #ffeb3b; color: #333; padding: 5px 10px; } #app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } </style> */
Debug
Known issues
breakingSince version 2.0.1, the element to which the `v-ripple` directive is attached *must* have `position: relative` in its CSS for the ripple effect to position correctly. While the directive attempts to temporarily set `position: relative` if missing, this can lead to unpredictable layout shifts or visual glitches, especially when elements are dynamically moved or resized.
fix
Explicitly add `position: relative;` to the CSS rules for all elements that use `v-ripple`. Also, ensure `overflow: hidden;` is applied to clip the ripple within the element's bounds.
affects: >=2.0.1
gotchaOlder versions of `vue-ripple-directive` (prior to 1.0.9 and 1.0.7) had issues with ES6 syntax not being properly transpiled, leading to compatibility problems in environments that did not support newer JavaScript features natively or had incorrect build configurations.
fix
Ensure you are using a recent version of the directive (2.0.x recommended). If targeting older browsers or environments, ensure your project's build pipeline (e.g., Babel) is correctly transpiling node_modules or specifically `vue-ripple-directive`.
affects: <1.0.9
Errors
Common errors & fixes
Ripple effect appears incorrectly positioned, extends beyond element boundaries, or is invisible.
The element applying the `v-ripple` directive does not have `position: relative` and/or `overflow: hidden` in its CSS.
fix
Add `position: relative;` and `overflow: hidden;` to the CSS class or style attribute of the element where `v-ripple` is used.
`Vue is not defined` or `app.directive is not a function` when registering the directive.
Vue instance (or `app` in Vue 3) is not correctly imported, globally available, or the directive registration syntax is incorrect for the Vue version being used.
fix
For Vue 3, ensure you `import { createApp } from 'vue'` and use `app.directive('ripple', Ripple)`. For Vue 2, ensure `import Vue from 'vue'` and use `Vue.directive('ripple', Ripple)`.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
vuerequiredRequired as a peer dependency for registering and utilizing the directive within a Vue application.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vue-ripple-directive — npm install vue-ripple-directive · libregistry