Popover
Use the Popover component to hide controls or options behind a clickable element.
Trap focus
If the Popover should be responsible for trapping the focus within itself (as opposed to a child component), then you should set ownFocus
.
Anchor position
The alignment and arrow on your popover can be set with the anchorPosition
prop. These positions will not update based upon screen real estate and will stick to the positions you declare. Because of this, be careful when using left or right positioning.
Some tips:
- The first word in the
anchorPosition
denotes where the popover will appear relative to the button. - The second word in the
anchorPosition
denotes where the gravity / pin position will appear relative to the popover.
Panel class name and padding size
Use the panelPaddingSize
prop to adjust the padding on the panel within the panel. Use the panelClassName
prop to pass a custom class to the panel inside a popover.
Popover with title and padding size
When using popover titles, you can still propogate the padding size by using panelPaddingSize
. This will only affect the horizontal padding of the title and the overall padding of the content.
Constraining a popover inside a container
EuiPopover
can accept a React or DOM element as a container
prop and restrict the popover from overflowing that container.
Popover using an HTMLElement as the anchor
EuiWrappingPopover
is an extra popover component that allows any existing DOM element to be passed as the button
prop.
Popover on a fixed element
Popover content even works on position: fixed;
elements.
Popover with block level display
Popover anchors default to display: inline-block
so they do not force block display on inline triggers. If you do need to change this to block display, just add display="block"
Popover attached to input element
EuiInputPopover
is a specialized popover component intended to be used with form elements. Stylistically, the popover panel is"attached" to the input. Functionally, consumers have control over what events open and close the popover, and it can allow for natural tab order.
Although some assumptions are made about keyboard behavior, consumers should provide specific key event handlers depending on the use case. For instance, a type=text
input could use the down key to trigger popover opening, but this interaction would not be appropriate for type=number
inputs as they natively bind to the down key.