# react-pressable

> Add onRelease, onReleaseInside, onReleaseOutside, and onPress events to a component

Latest version **0.2.0** (published 2014-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-pressable
pnpm add react-pressable
yarn add react-pressable
bun add react-pressable
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2014-12-23 |
| First published | 2014-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Matthew Dapena-Tretter |
| Maintainers | matthewwithanm, lettertwo |
| Keywords | react-component, react, events, onPress, onRelease, onReleaseInside, onReleaseOutside |

## Links

- npm: https://www.npmjs.com/package/react-pressable
- Repository: https://github.com/hzdg/react-pressable
- Issues: https://github.com/hzdg/react-pressable/issues
- npm.io page: https://npm.io/package/react-pressable

## Dependencies (2)

- [xtend](https://npm.io/package/xtend.md) ~4.0.0
- [eventlistener](https://npm.io/package/eventlistener.md) 0.0.1

## 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

- 0.2.0 (latest) — 2014-12-23
- 0.1.3 — 2014-05-08
- 0.1.2 — 2014-05-08
- 0.1.1 — 2014-05-08
- 0.1.0 — 2014-05-08

## README

react-pressable
===============

react-pressable is a [React] component that provides the convenience events
`onRelease`, `onReleaseOutside`, `onReleaseInside`, and `onPress`. It works with
any component that supports the normal React mouse events.


Installation
------------

[browserify] and [webpack] users can simply `npm install react-pressable`.

[Bower] users can `bower install react-pressable`.

You can also just download the react-pressable.js file from the standalone
directory in the repository.


Usage
-----

Composition is very easy:

```jsx
var Pressable = require('react-pressable');

var MyComponent = React.createClass({
    render: function () {
        return (
            <Pressable
                    component={ React.DOM.div }
                    onReleaseOutside={ this.handleReleaseOutside }>
                <span>Hello</span>
            </Presssable>
        );
    },
    handleReleaseOutside: function () {
        alert('You pressed the component but released the button outside!')
    }
})
```

However, Pressable also lets you create a pressable version of an existing
component using the `from` static method. This is often cleaner and avoids
markup pollution:

```jsx
var Pressable = require('react-pressable');
var PressableSpan = Pressable.from(React.DOM.span);

var MyComponent = React.createClass({
    render: function () {
        return (
            <PressableSpan onReleaseOutside={ this.handleReleaseOutside }>
                Hello
            </PresssableSpan>
        );
    },
    handleReleaseOutside: function () {
        alert('You pressed the component but released the button outside!')
    }
})
```


Event Types
-----------

<table>
    <tr>
        <th>Name</th>
        <th>Description</th>
    </tr>
    <tr>
        <td><code>onPress</code></td>
        <td>Currently the same as <code>onMouseDown</code>.</td>
    </tr>
    <tr>
        <td><code>onRelease</code></td>
        <td>
            Invoked when the mouse button is released after pressing the
            component, regardless of where the cursor is.
        </td>
    </tr>
    <tr>
        <td><code>onReleaseOutside</code></td>
        <td>
            Invoked when the mouse button is released after pressing the
            component, if the cursor is outside of the component.
        </td>
    </tr>
    <tr>
        <td><code>onReleaseInside</code></td>
        <td>
            Invoked when the mouse button is released after pressing the
            component, if the cursor is inside the component.
        </td>
    </tr>
</table>


[React]: http://reactjs.org
[browserify]: http://browserify.org
[webpack]: http://webpack.github.io
[Bower]: http://bower.io

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