Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/malcodeman/react-popover

The Popover component displays floating content in relation to a target.
https://github.com/malcodeman/react-popover

headless popover react react-hooks

Last synced: 2 months ago
JSON representation

The Popover component displays floating content in relation to a target.

Lists

README

        

# [react-popover](http://react-popover-storybook.surge.sh)

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/malcodeman/react-popover/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/v/@malcodeman/react-popover)](https://www.npmjs.com/package/@malcodeman/react-popover)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

The Popover component displays floating content in relation to a target. Popovers appear either at the top, bottom, left or right of their target. The preferred and default side is the bottom. Popovers use smart positioning if there is not enough space.

## Getting started

```sh
yarn add @malcodeman/react-popover
# or
npm install --save @malcodeman/react-popover
```

```jsx
import React from "react";
import { StatefulPopover } from "@malcodeman/react-popover";

function App() {
return (

PopoverContent
}>
Trigger Popover

);
}

export default App;
```

## Stateless example

```jsx
import React from "react";
import { Popover } from "@malcodeman/react-popover";

function App() {
const [isOpen, setIsOpen] = React.useState(false);

return (

PopoverContent
}>
setIsOpen(!isOpen)}>Trigger Popover

);
}

export default App;
```

## License

[MIT](./LICENSE)