All Projects → RobertMenke → react-popover

RobertMenke / react-popover

Licence: other
Customizable positioning for tooltips, menus, and any other DOM elements inside of a container

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-popover

floating-ui
A low-level toolkit to create floating elements. Tooltips, popovers, dropdowns, and more
Stars: ✭ 23,485 (+180553.85%)
Mutual labels:  popover, tooltip, positioning
React Popper
🍿⚛Official React library to use Popper, the positioning library
Stars: ✭ 2,173 (+16615.38%)
Mutual labels:  popover, tooltip, placement
react-popper
🍿⚛Official React library to use Popper, the positioning library
Stars: ✭ 2,415 (+18476.92%)
Mutual labels:  popover, tooltip, placement
Popper Core
🍿 JavaScript positioning library for tooltips, popovers, dropdowns, and more
Stars: ✭ 18,903 (+145307.69%)
Mutual labels:  popover, tooltip, positioning
Hibiscus.js
Native Angular directives for Bootstrap4
Stars: ✭ 115 (+784.62%)
Mutual labels:  popover, tooltip
Tippyjs
Tooltip, popover, dropdown, and menu library
Stars: ✭ 9,433 (+72461.54%)
Mutual labels:  popover, tooltip
React Layer Stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 152 (+1069.23%)
Mutual labels:  popover, tooltip
Ember Tooltips
Easy and extendible tooltips for Ember components - http://sir-dunxalot.github.io/ember-tooltips/
Stars: ✭ 205 (+1476.92%)
Mutual labels:  popover, tooltip
React Laag
Hooks to build things like tooltips, dropdown menu's and popovers in React
Stars: ✭ 568 (+4269.23%)
Mutual labels:  popover, tooltip
Popover
Angular CDK Popover, no default style, examples using @angular/material
Stars: ✭ 156 (+1100%)
Mutual labels:  popover, tooltip
Helipopper
🚁 A Powerful Tooltip and Popover for Angular Applications
Stars: ✭ 215 (+1553.85%)
Mutual labels:  popover, tooltip
Tippyjs React
React component for Tippy.js (official)
Stars: ✭ 1,081 (+8215.38%)
Mutual labels:  popover, tooltip
Ng Bootstrap
Angular powered Bootstrap
Stars: ✭ 7,872 (+60453.85%)
Mutual labels:  popover, tooltip
React Popper Tooltip
A React hook to effortlessly build smart tooltips.
Stars: ✭ 149 (+1046.15%)
Mutual labels:  popover, tooltip
Sveltejs Tippy
Tippy.js for Svelte
Stars: ✭ 26 (+100%)
Mutual labels:  popover, tooltip
toppy
Overlay library for Angular 7+
Stars: ✭ 81 (+523.08%)
Mutual labels:  popover, tooltip
react-layer-stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 158 (+1115.38%)
Mutual labels:  popover, tooltip
React Cool Portal
😎 🍒 React hook for Portals, which renders modals, dropdowns, tooltips etc. to <body> or else.
Stars: ✭ 458 (+3423.08%)
Mutual labels:  popover, tooltip
You Dont Need Javascript
CSS is powerful, you can do a lot of things without JS.
Stars: ✭ 16,514 (+126930.77%)
Mutual labels:  popover, tooltip
react-native-popable
Popovers, tooltips for React Native
Stars: ✭ 298 (+2192.31%)
Mutual labels:  popover, tooltip

Alt text

Why this positioning library?

Many positioning libraries in an effort to be simple assume static positioning and have no sense of the container they get appended to (often the document's body).

I wanted to build a positioning component that could handle relative and absolute positioned containers, could scroll with its container, could be used as a general-purpose positioning mechanism, and was dead-simple to use.

If you like the way the library has been written, or find it useful in your own project don't forget to star it!

Installation

yarn

yarn add rm-react-popover

npm

npm install rm-react-popover --save

Usage

import React, { Component } from "react"
import Popover from "rm-react-popover"

//Then, inside of your components render method
class Example extends Component {
    render() {
        return (
                <Popover
                    //Some HTML element to place the markup in
                    parent={this.container} 
                    //some HTML element to stick the menu to
                    element={this.element} 
                     //Can be a string, or an array of string like ["left", "top"]. Possible values are auto, left, right, top, bottom, element_left, element_right
                     //element_left and element_right align the left or right edge of your menu to the left or right edge of an element
                    placement="auto"
                    //When open is true, the markup is visible, when false it's invisible (but still in the DOM)
                    open={false}
                    //The top_cushion will add additional vertical space between your element
                    //and the element it sticks to. This is useful for things like pseudo
                    //elements used as triangle pointers.
                    top_cushion={10}
                    //left_cushion is just like top_cushion. It adds additional horizontal space between
                    //your popover/tooltip and the element you're sticking it to
                    left_cushion={-50}
                    //classes allows you to pass in a string or array of strings that will be applied
                    //as class names to the markup. rm-react-popover applies classes internally to
                    //keep track of which positions were applied, but the classes prop will always
                    //come before the internal classes
                    classes={["custom", "css-classes"]}
                >
                    <span>I was called with placement="auto"</span>
                </Popover>
        )
    }    
}

rm-react-tooltip does not come with any css applied out of the box. This is intentional as this is intended to be a general-purpose positioning library that can accept arbitrary markup as children of the component.

I have an example of what the styling of a tooltip might look like in the src folder, and it's also the stylesheet used in the example folder.

Every placement option has a corollary css class that gets applied, so that you can intelligently style your component based on its position. That mapping looks like this.

top            = TooltipAbove
bottom         = TooltipBelow
right          = TooltipRight
left           = TooltipLeft
element_right  = TooltipAlignRight
element_left   = TooltipAlignLeft
auto           = autoplace

Props

It may be helpful to look at the flow type definition for the component's props

type Props = {
    element         : HTMLElement,
    parent          : HTMLElement,
    placement       : string | Array<string>,
    open            : boolean,
    classes         : ?string | ?Array<string>,
    left_cushion    : ?number,
    top_cushion     : ?number,
    children        : Array<Element>
}

Dependencies

For obvious reasons:

  • React
  • React DOM

Webpack build instructions

I use one webpack configuration to build the library and a second configuration to build out the example.

Building the library: npm start

Building the example: npm run build-example

Both example.webpack.config.js and webpack.config.js define a variable called is_production at the top of the file. This variable controls which plugins get loaded. It may be helpful while developing to set this variable to false in order to use source maps in the browser.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].