npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@alterai/ripple

v1.0.0

Published

This package is compatible with React 19 and above. It leverages the latest features and improvements in React 19 to provide a smooth and efficient ripple effect. Make sure to have React 19 or later installed in your project to use this package.

Downloads

4

Readme

Ripple Component and useRipple Hook Documentation

This package is compatible with React 19 and above. It leverages the latest features and improvements in React 19 to provide a smooth and efficient ripple effect. Make sure to have React 19 or later installed in your project to use this package. 

Overview

The Ripple component and useRipple hook are used to create a material design ripple effect, which is a visual feedback mechanism for user interactions. The ripple effect is commonly used in buttons, cards, and other interactive elements.

Ripple Component

Props

  • as: (Optional) The HTML element or SVG element to render as the container for the ripple effect. Defaults to 'div'.
  • color: (Optional) The color of the ripple effect. Can be any valid CSS color value.
  • centered: (Optional) If true, the ripple effect will originate from the center of the container. Defaults to false.
  • radius: (Optional) The radius of the ripple effect. If not provided, the ripple will expand to the furthest corner of the container.
  • disabled: (Optional) If true, the ripple effect will be disabled. Defaults to false.
  • unbounded: (Optional) If true, the ripple effect will not be constrained by the container's boundaries. Defaults to false.
  • animation: (Optional) Configuration for the ripple animation.
    • enterDuration: (Optional) The duration of the ripple's enter animation in milliseconds. Defaults to 225.
    • exitDuration: (Optional) The duration of the ripple's exit animation in milliseconds. Defaults to 150.
  • terminateOnPointerUp: (Optional) If true, the ripple effect will terminate when the pointer is released. Defaults to false.

Usage

import React from 'react';
import { Ripple } from '@alterai/ripple';

function MyButton() {
  return (
    <Ripple color="rgba(0, 0, 0, 0.1)" centered style={{ padding: '10px 20px', borderRadius: '5px', backgroundColor: '#007bff', color: '#fff', border: 'none', cursor: 'pointer' }}>
        Click Me
    </Ripple>
  );
}

export default MyButton;

useRipple Hook

Parameters

  • config: (Optional) Configuration object for the ripple effect.
    • color: (Optional) The color of the ripple effect. Can be any valid CSS color value.
    • centered: (Optional) If true, the ripple effect will originate from the center of the container. Defaults to false.
    • radius: (Optional) The radius of the ripple effect. If not provided, the ripple will expand to the furthest corner of the container.
    • persistent: (Optional) If true, the ripple effect will persist until manually faded out. Defaults to false.
    • disabled: (Optional) If true, the ripple effect will be disabled. Defaults to false.
    • animation: (Optional) Configuration for the ripple animation.
      • enterDuration: (Optional) The duration of the ripple's enter animation in milliseconds. Defaults to 225.
      • exitDuration: (Optional) The duration of the ripple's exit animation in milliseconds. Defaults to 150.
    • terminateOnPointerUp: (Optional) If true, the ripple effect will terminate when the pointer is released. Defaults to false.

Return Value

  • containerRef: A ref that should be attached to the container element where the ripple effect will be applied.
  • launch: A function to manually trigger a ripple effect at a specific coordinate.
    • Parameters:
      • x: The x-coordinate of the ripple's origin.
      • y: The y-coordinate of the ripple's origin.
      • config: (Optional) Configuration object for the ripple effect.
  • fadeOutAll: A function to fade out all active ripples.
  • fadeOutAllNonPersistent: A function to fade out all non-persistent ripples.

Usage

import React, { useRef } from 'react';
import { useRipple } from '@alterai/ripple';

function MyButton() {
  const { containerRef } = useRipple({ color: 'rgba(0, 0, 0, 0.1)', centered: true });

  return (
    <button ref={containerRef} style={{ padding: '10px 20px', borderRadius: '5px', backgroundColor: '#007bff', color: '#fff', border: 'none', cursor: 'pointer' }}>
      Click Me
    </button>
  );
}

export default MyButton;

Examples

Centered Ripple

<Ripple as="button" color="rgba(0, 0, 0, 0.1)" centered style={{ padding: '10px 20px', borderRadius: '5px', backgroundColor: '#007bff', color: '#fff', border: 'none', cursor: 'pointer' }}>
    Centered Ripple
</Ripple>

Custom Radius Ripple

<Ripple as="button" color="rgba(0, 0, 0, 0.1)" radius={50} style={{ padding: '10px 20px', borderRadius: '5px', backgroundColor: '#007bff', color: '#fff', border: 'none', cursor: 'pointer' }}>
    Custom Radius Ripple
</Ripple>

Persistent Ripple

<Ripple as="button" color="rgba(0, 0, 0, 0.1)" persistent style={{ padding: '10px 20px', borderRadius: '5px', backgroundColor: '#007bff', color: '#fff', border: 'none', cursor: 'pointer' }}>
    Persistent Ripple
</Ripple>

Unbounded Ripple

<Ripple as="button" color="rgba(0, 0, 0, 0.1)" unbounded style={{ padding: '10px 20px', borderRadius: '5px', backgroundColor: '#007bff', color: '#fff', border: 'none', cursor: 'pointer' }}>
    Unbounded Ripple
</Ripple>

Custom Animation Duration

<Ripple as="button" color="rgba(0, 0, 0, 0.1)" animation={{ enterDuration: 500, exitDuration: 300 }} style={{ padding: '10px 20px', borderRadius: '5px', backgroundColor: '#007bff', color: '#fff', border: 'none', cursor: 'pointer' }}>
  Custom Animation Duration
</Ripple>

Manual Ripple Trigger with launch

import React, { useRef } from 'react';
import { useRipple } from '@alterai/ripple';

function MyCustomComponent() {
  const { containerRef, launch } = useRipple({ color: 'rgba(0, 0, 0, 0.1)' });

  const handleClick = (event) => {
    const rect = event.currentTarget.getBoundingClientRect();
    const x = event.clientX - rect.left;
    const y = event.clientY - rect.top;
    launch(x, y);
  };

  return (
    <div ref={containerRef} onClick={handleClick} style={{ padding: '20px', borderRadius: '10px', backgroundColor: '#f8f9fa', border: '1px solid #ddd', cursor: 'pointer', textAlign: 'center' }}>
      Click anywhere in this box
    </div>
  );
}

export default MyCustomComponent;

Notes

  • The Ripple component is a wrapper that automatically handles the ripple effect for its children.
  • The useRipple hook provides more control and can be used in custom components where the Ripple component might not be suitable.
  • The ripple effect is designed to work with both HTML elements and SVG elements.