Edit this page

up.layer up.layer.config
JavaScript property

Configures default attributes for new overlays.

All options for up.layer.open() may be configured. The configuration will also be used for a[up-layer=new] links.

Defaults are configured separately for each layer mode:

Object Effect
up.layer.config.root Defaults for the root layer
up.layer.config.modal Defaults for modal overlays
up.layer.config.drawer Defaults for drawer overlays
up.layer.config.popup Defaults for popup overlays
up.layer.config.cover Defaults for cover overlays

For convenience you may configure options that affect all layer modes or all overlay modes:

Object Effect
up.layer.config.any Defaults for all layers
up.layer.config.overlay Defaults for all overlays

Options configured in such a way are inherited. E.g. when you open a new drawer overlay, defaults from up.layer.config.drawer, up.layer.config.overlay and up.layer.config.any will be used (in decreasing priority).

Example

To make all modal overlays move in from beyond the top edge of the screen:

up.layer.config.modal.openAnimation = 'move-from-top'

To configure an additional main target for overlay of any mode:

up.layer.config.overlay.mainTargets.unshift('.content')

Configuration inheritance

Value

[config.mode='modal'] string optional

The default mode used when opening a new overlay.

config.any Object

Defaults for all layer modes.

config.any.mainTargets Array<string>

An array of CSS selectors matching default render targets.

This is an alias for up.fragment.config.mainTargets.

config.root Object

Defaults for the root layer.

Inherits from up.layer.config.any.

config.root.mainTargets Object

An array of CSS selectors matching default render targets for the root layer, but not for overlays.

config.overlay Object

Defaults for all overlays.

In addition to the options documented here, all options for up.layer.open() may also be configured.

Inherits from up.layer.config.any.

config.overlay.openAnimation stringorFunction

The opening animation.

config.overlay.openDuration number

The duration of the opening animation.

config.overlay.openEasing string

The easing function for the opening animation.

config.overlay.closeAnimation stringorFunction

The closing animation.

config.overlay.closeDuration number

The duration of the closing animation.

config.overlay.closeEasing string

The easing function for the opening animation.

config.overlay.dismissLabel string

The symbol for the dismiss icon in the top-right corner.

config.overlay.dismissAriaLabel string

The accessibility label for the dismiss icon in the top-right corner.

[config.overlay.history='auto'] stringorboolean optional

Whether the layer's location or title will be visible in the browser's address bar and window title.

If set to 'auto', the overlay will render history if its initial fragment is an auto history target.

If set to true, the overlay will always render history. If set to false, the overlay will never render history.

[config.overlay.class] string optional

An HTML class for the overlay's container element.

See overlay classes.

config.modal Object

Defaults for modal overlays.

Inherits from up.layer.config.overlay and up.layer.config.any.

config.cover Object

Defaults for cover overlays.

Inherits from up.layer.config.overlay and up.layer.config.any.

config.drawer Object

Defaults for drawer overlays.

Inherits from up.layer.config.overlay and up.layer.config.any.

config.popup Object

Defaults for popup overlays.

Inherits from up.layer.config.overlay and up.layer.config.any.

config.foreignOverlaySelectors Array<string>

An array of CSS selectors matching overlays not constructed by Unpoly.

Other JavaScript libraries often attach their overlay elements to the end of the <body>, which makes Unpoly consider these overlays to be part of the root layer. This can cause Unpoly to steal focus from foreign overlays, or cause Unpoly overlays to incorrectly close when the foreign overlay is clicked. Adding a selector to this array will cause Unpoly to be less opinionated about user interactions within matching elements.

By default this contains a selector matching the <dialog> element.