1.0.4 • Published 4 years ago

react-light-popover v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

React Light Popover

A lightweight weight (1kb), zero dependancy popover component for React

Examples

See demo here

Features

  • Render popover inside a portal
  • Supports positions left, right, top, bottom
  • Supports align center (default), start, end
  • Persist on scroll
  • Switch direction on boundary violation with window
  • Highly customisable no wrapper elements are created on content or target element.

Documentation

Installation

$ npm i --save react-light-popover
# or
$ yarn add react-light-popover

Sample Usage

import { Popover } from "react-light-popover";

function App() {
  const [show, setShow] = useState(false);

  return (
    <>
      <Popover
        show={show}
        positions={["left", "bottom"]}
        align={"center"}
        offset={10}
        content={<div className="content__styles">Hello</div>}
        onClose={() => setShow(false)}
      >
        <button type="button" onClick={() => setShow(!show)}>
          Show popover
        </button>
      </Popover>
    </>
  );
}

Props

PropTypeDescription
showbooleanShow or hide popover.
positionsstring[]Determines the positions in which the popover appear. Possible values left, right, top or bottom. By default popover appears on the first position in the array if there is a boundary violation with window it takes the next position if available.
alignstringDetermines the alignment of the content, Possible values are start, end and center. By default it will be center.
contentReactElementContent to be rendered inside the popover.
onCloseFunctionThis function is called when popover on body click when popover is open.
childrenReactElementTarget element to which the popover is attached
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago