Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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: 11 days ago
JSON representation

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

Awesome Lists containing this project

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)