ons-popover

A component that displays a popover next to an element. The popover can be used to display extra information about a component or a tooltip. To use the element it can either be attached directly to the <body> element or dynamically created from a template using the ons.createPopover(template) utility function and the <template> tag. Another common way to use the popover is to display a menu when a button on the screen is tapped. For Material Design, popover looks exactly as a dropdown menu.

Tutorial

Tutorial will be added soon.

See also

Name Type Description
modifier String The appearance of the popover. Optional.
direction String

A space separated list of directions. If more than one direction is specified, it will be chosen automatically. Valid directions are "up", "down", "left" and "right".

Optional.
cancelable If this attribute is set the popover can be closed by tapping the background or by pressing the back button. Optional.
cover-target If set the popover will cover the target on the screen. Optional.
target String Specifies the ID of the default element for the popover. Optional.
animation String The animation used when showing an hiding the popover. Can be either "none", "default", "fade-ios" or "fade-md". Optional.
animation-options Expression Specify the animation’s duration, timing and delay with an object literal. E.g. {duration: 0.2, delay: 1, timing: 'ease-in'}. Optional.
mask-color Color Color of the background mask. Default is "rgba(0, 0, 0, 0.2)". Optional.
visible Boolean Whether the popover is visible or not. Optional.
Name Description
coverTarget If set the popover will cover the target on the screen.
target Specifies the ID of the default element for the popover.
animationOptions Specify the animation’s duration, timing and delay with an object literal. E.g. {duration: 0.2, delay: 1, timing: 'ease-in'}.
visible Whether the element is visible or not.
cancelable

A boolean value that specifies whether the popover is cancelable or not. When the popover is cancelable it can be closed by tapping the background or by pressing the back button on Android devices.

onDeviceBackButton Back-button handler.
maskColor Color of the background mask. Default is “rgba(0, 0, 0, 0.2)”.
Signature Description
show(target, [options]) Open the popover and point it at a target. The target can be either an event, a CSS selector or a DOM element..
hide([options]) Close the popover.
show(target, [options]): Promise

Open the popover and point it at a target. The target can be either an event, a CSS selector or a DOM element..

Returns: Resolves to the displayed element

Parameters
Name Type Description
target String|Event|HTMLElement Target element. Can be either a CSS selector, an event object or a DOM element. It can be also provided as ‘options.target’ instead.
options Object Parameter object.
options.animation String Animation name. Use one of "fade-ios", "fade-md", "none" and "default".
options.animationOptions String Specify the animation’s duration, delay and timing. E.g. {duration: 0.2, delay: 0.4, timing: 'ease-in'}.
options.callback Function This function is called after the popover has been revealed.
hide([options]): Promise

Close the popover.

Returns: Resolves to the hidden element

Parameters
Name Type Description
options Object Parameter object.
options.animation String Animation name. Use one of "fade-ios", "fade-md", "none" and "default".
options.animationOptions String Specify the animation’s duration, delay and timing. E.g. {duration: 0.2, delay: 0.4, timing: 'ease-in'}.
options.callback Function This functions is called after the popover has been hidden.
Name Description
preshow Fired just before the popover is displayed.
postshow Fired just after the popover is displayed.
prehide Fired just before the popover is hidden.
posthide Fired just after the popover is hidden.
dialogcancel Fired when the popover is canceled.
preshow

Fired just before the popover is displayed.

Parameters
Name Type Description
event Object Event object.
event.popover Object Component object.
event.cancel Function Call this function to stop the popover from being shown.
postshow

Fired just after the popover is displayed.

Parameters
Name Type Description
event Object Event object.
event.popover Object Component object.
prehide

Fired just before the popover is hidden.

Parameters
Name Type Description
event Object Event object.
event.popover Object Component object.
event.cancel Function Call this function to stop the popover from being hidden.
posthide

Fired just after the popover is hidden.

Parameters
Name Type Description
event Object Event object.
event.popover Object Component object.
dialogcancel

Fired when the popover is canceled.

Parameters
Name Type Description

Need Help?

If you have any questions, use our Community Forum or talk to us on Discord chat. The Onsen UI team and your peers in the community will work together to help solve your issues.

For bug reports and feature requests use our GitHub Issues page.