Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@leafygreen-ui/popover

Package Overview
Dependencies
Maintainers
5
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafygreen-ui/popover

LeafyGreen UI Kit Popover

  • 11.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26K
decreased by-33.17%
Maintainers
5
Weekly downloads
 
Created
Source

Popover

npm (scoped)

View on MongoDB.design

Installation

Yarn

yarn add @leafygreen-ui/popover

NPM

npm install @leafygreen-ui/popover

Example

import Popover from '@leafygreen-ui/popover';

<button
  className={containerStyle}
  onClick={() => this.setState({ active: !this.state.active })}
>
  Popover
  <Popover
    align="bottom"
    justify="start"
    active={this.state.active}
    usePortal={true}
    spacing={10}
  >
    <div className={popoverStyle}>Popover content</div>
  </Popover>
</button>;

Output HTML

<button class="leafygreen-ui-79elbk">
  Popover
  <div class="leafygreen-ui-1hyfx7x"></div>
</button>

<div align="bottom" justify="start" class="leafygreen-ui-1t5dnko">
  <div class="leafygreen-ui-ii2v5b">Popover content</div>
</div>

Simple Use Case

The popover component will be automatically positioned relative to its nearest parent. If usePortal is set to false, then it will be positioned relative to its nearest ancestor with the CSS property: position: absolute | relative | fixed.

Properties

PropTypeDescriptionDefault
activebooleanDetermines whether the Popover is active or inactivefalse
align'top' | 'bottom' | 'left' | 'right' | 'center-horizontal' | 'center-vertical'A string that determines the alignment of the popover relative to the refEl.'bottom'
justify'start' | 'middle' | 'end' | 'fit'A string that determines the justification of the popover relative to the refEl. Justification will be defined relative to the align prop'start'
childrennodeContent that will appear inside of the <Popover /> component
spacingnumberSpecifies the amount of spacing (in pixels) between the trigger element and the content element.10
classNamestringClassname to apply to popover-content container
adjustOnMutationbooleanShould the Popover auto adjust its content when the DOM changes (using MutationObserver).false
onClickfunctionFunction that will be called when popover content is clicked.
usePortalbooleanWill position Popover's children relative to its parent without using a Portal, if usePortal is set to false. NOTE: The parent element should be CSS position relative, fixed, or absolute if using this option.true
portalContainerHTMLElement | nullSets the container used for the popover's portal. NOTE: If using a scrollContainer make sure that the portalContainer is contained within the scrollContainer. E.g, passing the same reference to scrollContainer and portalContainer.
scrollContainerHTMLElement | nullIf the popover portal has a scrollable ancestor other than the window, this prop allows passing a reference to that element to allow the portal to position properly.
portalClassNamestringPasses the given className to the popover's portal container if the default portal container is being used.
popoverZIndexnumberSets the z-index CSS property for the popover.
...native attributes of Portal or FragmentAny other properties will be spread on the popover-content container

Advanced Use Case

PropTypeDescriptionDefault
refElHTMLElementYou can supply a refEl prop, if you do not want the popover to be positioned relative to it's nearest parent. Ref to the element to which the popover component should be positioned relative to.null

FAQs

Package last updated on 13 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc