leafyGreen UI Kit Ripple
npm install @leafygreen-ui/ripple``shell`
pnpm add @leafygreen-ui/ripple
`shell`
yarn add @leafygreen-ui/ripple
`shell`
npm install @leafygreen-ui/ripple
`js
import { registerRipple } from '@leafygreen-ui/ripple';
// JavaScript Example
const button = document.querySelector('#my-button');
const buttonOptions = {
variant: 'danger',
darkMode: false,
};
registerRipple(button, buttonOptions);
// React Example
function Button({ options }) {
const ref = React.useRef(null);
useEffect(() => {
if (ref.current) {
registerRipple(ref, options);
}
}, [ref, options]);
}
`
| Argument | Type | Description | Default |
| ---------------- | ------------------------------------------------------------------- | ------------------------------------------------------------- | ------- |
| ref | HTMLElement | HTMLElement that ripple effect should be applied to | |'primary'
| options | | Options that specify coloring and size of ripple | |
| options.variant | , 'info', 'default', 'danger', 'secondaryDanger' | Determines color of ripple effect | |boolean
| options.darkMode | | Determines if the ripple effect will be rendered in dark mode | false |
_NOTE: In order for this to work as expected, the target element must have the property overflow:hidden` set_