JSPM

  • Created
  • Published
  • Downloads 178157
  • Score
    100M100P100Q170895F
  • License MIT

Render a portal positioned relative to another element.

Package Exports

  • @reach/popover

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@reach/popover) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@reach/popover

Stable release MIT license

import * as React from "react";
import { Popover, positionDefault } from "@reach/popover";

function Example() {
    const ref = React.useRef(null);
    const [value, setValue] = React.useState("");
    return (
        <div>
            <label>
                <span>Type for a special message</span>
                <input
                    type="text"
                    ref={ref}
                    onChange={(event) => setValue(event.target.value)}
                />
            </label>

            {value.length > 0 && (
                <Popover targetRef={ref} position={positionDefault}>
                    <div>
                        <p>Whoa! Look at me!</p>
                    </div>
                </Popover>
            )}
        </div>
    );
}