# react-float-affixed

> a component to float elements in a separate layer but affixed to anchors in the main tree, useful for things like dropdowns, tooltips, menu buttons etc...

Latest version **1.0.0** (published 2018-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-float-affixed
pnpm add react-float-affixed
yarn add react-float-affixed
bun add react-float-affixed
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-10 |
| First published | 2015-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Warren Falk |
| Maintainers | warrenfalk |
| Keywords | react, popup, popout, dropdown, tooltips, float, react-component |

## Links

- npm: https://www.npmjs.com/package/react-float-affixed
- Repository: https://github.com/warrenfalk/react-float-affixed
- Homepage: https://github.com/warrenfalk/react-float-affixed#readme
- Issues: https://github.com/warrenfalk/react-float-affixed/issues
- npm.io page: https://npm.io/package/react-float-affixed

## Dependencies (3)

- [pex-geom](https://npm.io/package/pex-geom.md) ^0.14.0
- [classnames](https://npm.io/package/classnames.md) ^2.2.5
- [prop-types](https://npm.io/package/prop-types.md) 15.6.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

- 1.0.0 (latest) — 2018-05-10
- 0.1.3-b (beta) — 2016-04-07
- 0.1.11 — 2018-03-19
- 0.1.10 — 2018-03-19
- 0.1.9 — 2018-03-19
- 0.1.8 — 2016-10-13
- 0.1.7 — 2016-09-13
- 0.1.6 — 2016-08-15
- 0.1.5 — 2016-08-15
- 0.1.4 — 2016-04-07
- 0.1.2 — 2016-04-07
- 0.1.1 — 2015-12-18
- 0.1.0 — 2015-12-04
- 0.0.5 — 2015-12-04
- 0.0.4 — 2015-12-03
- … 3 more at https://npm.io/package/react-float-affixed/versions

## README

# react-float-affixed

Create popup elements that are attached to other elements (such as what you might use to implement a dropdown or menu button).

The popup is created *outside* of the regular DOM tree but is positioned to remain automatically attached to the element to which you anchor it, automatically switching which edge it is attached to in order to stay on the screen.

## Demonstration

![Demonstration](docs/animated-demo.gif)

Usage:

![Preview](docs/figure01.png)

```jsx
<button>
    <span>This is my button</span>
    <FloatAffixed>and this is my popup</FloatAffixed>
</button>
```

Results in html that looks like this
```html
<button><span>This is my button</span></button>
```

And html elsewhere that looks like this:
```html
<div>and this is my popup</div>
```

## Advanced
More advanced usage, here's an example that shows the popup when the button is clicked

### Show and hide a popup
```jsx
<div>
    <input type="checkbox" checked={this.state.on} onClick={()=>this.setState({on:!this.state.on})}/>
    <label>This is my checkbox</label>
    {this.state.on &&
        <FloatAffixed>This is my popup</FloatAffixed>
    }
</div>
```

### Specify valid attachment edges
```jsx
<FloatAffixed attachments="over,under">...</FloatAffixed>
```
Note: edges are tried in the order specified

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