11.3.1 • Published 1 month ago

@leafygreen-ui/popover v11.3.1

Weekly downloads
369
License
Apache-2.0
Repository
github
Last release
1 month ago

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
11.3.1

1 month ago

11.3.0

2 months ago

11.2.2

4 months ago

11.2.2-popover.0

4 months ago

11.2.1

4 months ago

11.0.17

9 months ago

11.0.18

8 months ago

11.0.15

9 months ago

11.0.16

9 months ago

11.0.13

10 months ago

11.0.14

9 months ago

11.2.0

6 months ago

12.0.0-alpha.1

10 months ago

12.0.0-alpha.0

10 months ago

11.1.1

7 months ago

11.1.0

8 months ago

11.0.10

11 months ago

11.0.11

11 months ago

11.0.12

11 months ago

11.0.9

12 months ago

11.0.10-next.0

12 months ago

11.0.10-next.2

12 months ago

11.0.10-next.1

12 months ago

11.0.10-next.4

12 months ago

11.0.10-next.3

12 months ago

11.0.10-next.6

12 months ago

11.0.10-next.5

12 months ago

11.0.10-next.7

12 months ago

11.0.6

1 year ago

11.0.7

1 year ago

11.0.8

1 year ago

11.0.5

1 year ago

11.0.4

1 year ago

11.0.2

1 year ago

11.0.3

1 year ago

11.0.0

1 year ago

11.0.1

1 year ago

10.0.0

2 years ago

10.0.1

2 years ago

9.1.1

2 years ago

9.1.0

2 years ago

9.1.0-test.0

2 years ago

9.1.0-next.2

2 years ago

9.1.0-next.0

2 years ago

9.1.0-next.1

2 years ago

9.0.1

2 years ago

8.0.1

2 years ago

9.0.0

2 years ago

7.2.3

2 years ago

8.0.0

2 years ago

7.2.2

3 years ago

7.2.1

3 years ago

7.2.0

3 years ago

7.1.4

3 years ago

7.1.3

3 years ago

7.1.2

3 years ago

7.1.1

3 years ago

7.1.0

3 years ago

7.0.1

4 years ago

7.0.0

4 years ago

6.0.0

4 years ago

5.2.3

4 years ago

5.2.2

4 years ago

5.2.1

4 years ago

5.2.0

4 years ago

5.1.4

4 years ago

5.1.3

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.0

5 years ago

1.2.0

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago