# svelte-ripple-action

> A svelte action to add a ripple effect to any element

Latest version **2.0.0** (published 2024-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install svelte-ripple-action
pnpm add svelte-ripple-action
yarn add svelte-ripple-action
bun add svelte-ripple-action
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-11-15 |
| First published | 2023-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 61 |
| Author | posandu |
| Maintainers | tronic247 |

## Links

- npm: https://www.npmjs.com/package/svelte-ripple-action
- Repository: https://github.com/posandu/svelte-ripple-action
- Homepage: https://github.com/posandu/svelte-ripple-action#readme
- Issues: https://github.com/posandu/svelte-ripple-action/issues
- npm.io page: https://npm.io/package/svelte-ripple-action

## Recent versions

- 2.0.0 (latest) — 2024-11-15
- 1.0.6 — 2024-03-14
- 1.0.5 — 2024-01-08
- 1.0.4 — 2023-09-28
- 1.0.3 — 2023-09-10
- 1.0.2 — 2023-08-12
- 1.0.1 — 2023-08-12
- 1.0.0 — 2023-08-12

## README

# Svelte Ripple Action

<p>
  <img
			src="https://deno.bundlejs.com/badge?q=svelte-ripple-action"
			alt=""
	/>
  <img src="https://img.shields.io/github/commit-activity/t/posandu/svelte-ripple-action" />
  <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/posandu/svelte-ripple-action">
</p>

View the [demo](https://ripple.posandu.com/).

Svelte Ripple Action is a simple and customizable action for creating ripple effects on elements in a Svelte application.

## Installation

Install the package from npm or your preferred package manager:

```bash
npm install svelte-ripple-action
```

## Usage

1. Import the CSS styles for the ripple effect:

```javascript
import "svelte-ripple-action/ripple.css";
```

2. Import the `ripple` action and use it on any element you want to have a ripple effect on:

```svelte
<script>
  import { ripple } from "svelte-ripple-action";
</script>

<button use:ripple>Click me</button>
```

That's it! You now have a ripple effect on your element.

## Options

You can pass options to customize the ripple effect.

### `center?: boolean`

By default, the ripple effect starts from the point where the user clicks on the element. If you want the ripple effect to start from the center of the element, you can pass the `center` option.

```svelte
<button use:ripple={{ center: true }}>Click me</button>
```

### `color?: string`

You can customize the color of the ripple effect by passing a valid CSS color value to the `color` option.

```svelte
<button
  use:ripple={{
    color: "rgba(255, 0, 0, 0.2)",
  }}
>Red ripple</button>
```

### `duration?: number`

You can control the duration of the ripple effect in seconds by passing a number to the `duration` option.

```svelte
<button use:ripple={{ duration: 2 }}>2 seconds</button>
<button use:ripple={{ duration: 0.2 }}>0.2 seconds</button>
```

### `maxRadius?: number`

You can control the maximum radius of the ripple effect in pixels by passing a number to the `maxRadius` option.

```svelte
<button use:ripple={{ maxRadius: 100 }}>100px</button>
```

## Credits

Created by [Posandu](https://posandu.com). You can find the source code on [GitHub](https://github.com/posandu/svelte-ripple-action).

---
_Source: https://npm.io/package/svelte-ripple-action · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
