# @react-sandbox/heart

> Animated heart button

Latest version **1.1.0** (published 2024-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @react-sandbox/heart
pnpm add @react-sandbox/heart
yarn add @react-sandbox/heart
bun add @react-sandbox/heart
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-03-14 |
| First published | 2023-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | William Grosset |
| Maintainers | williamgrosset |
| Keywords | react, typescript, heart, button, react-heart |

## Links

- npm: https://www.npmjs.com/package/@react-sandbox/heart
- Repository: https://github.com/react-sandbox/heart
- Issues: https://github.com/react-sandbox/heart/issues
- npm.io page: https://npm.io/package/@react-sandbox/heart

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2024-03-14
- 1.0.0 — 2023-08-29

## README

<h1 align="center">
  <a href="https://www.npmjs.com/package/@react-sandbox/heart">@react-sandbox/heart</a>
</h1>

<p align="center">
  <img src="https://img.shields.io/github/actions/workflow/status/react-sandbox/heart/playwright.yml" alt="Build status" />
  <img src="https://img.shields.io/badge/dependencies-0-brightgreen" alt="Dependencies" />
  <img src="https://img.shields.io/bundlephobia/minzip/@react-sandbox/heart?color=%234ba0f6" alt="Build size" />
  <img src="https://img.shields.io/npm/dt/@react-sandbox/heart?color=%234ba0f6" alt="Package downloads" />
</p>

<p align="center">
  <img src="example.gif" alt="Example" />
</p>

<p align="center">❤️ Animated heart button.</p>

## Usage

### Install

Install the `@react-sandbox/heart` package:

```
npm install @react-sandbox/heart
```

### Import

Import the `Heart` component:

```tsx
import React, { useState } from 'react'
import Heart from '@react-sandbox/heart'

function App() {
  const [active, setActive] = useState(false)

  return (
    <div>
      <Heart
        width={24}
        height={24}
        active={active}
        onClick={() => setActive(!active)}
      />
    </div>
  )
}
```

### Props

| Prop            | Type                  | Default      | Description             |
| --------------- | --------------------- | ------------ | ----------------------- |
| `width`         | `number`              | **required** | Heart width             |
| `height`        | `number`              | **required** | Heart height            |
| `active`        | `boolean`             | **required** | Heart fill & animation  |
| `onClick`       | `function`            | **required** | Click callback function |
| `activeColor`   | `string`              | `'#ff0000'`  | Active color            |
| `inactiveColor` | `string`              | `'#121212'`  | Inactive color          |
| `strokeWidth`   | `number`              | `30`         | Outline stroke width    |
| `disabled`      | `boolean`             | `false`      | Disable usage           |
| `ariaLabel`     | `string`              | `'Like'`     | Accessibility label     |
| `className`     | `string`              | `-`          | CSS classes             |
| `style`         | `React.CSSProperties` | `-`          | CSS styles              |

## Development

### Local

```
pnpm install
pnpm dev
```

### Tests

```
pnpm test
```

### Example

Inside `test/`:

```
pnpm install
pnpm dev
```

## License

MIT

---
_Source: https://npm.io/package/@react-sandbox/heart · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
