---
name: "up.Layer"
area: "API"
kind: "class"
parent: "up.layer module"
url: "https://unpoly.com/api/up.Layer"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.layer module](https://unpoly.com/api/up.layer.md)</nav>

# `up.Layer`

Each layer has an `up.Layer` instance.

Most functions in the [`up.layer`](https://unpoly.com/api/up.layer.md) package interact with the [current layer](https://unpoly.com/api/up.layer.current.md). For example, [`up.layer.dismiss()`](https://unpoly.com/api/up.layer.dismiss.md) is a shortcut for `up.layer.current.dismiss()`.

[`up.layer.current`](https://unpoly.com/api/up.layer.current.md) is set to the right layer in compilers and most events, even if that layer is not the frontmost layer. E.g. if you're compiling a fragment for a background layer, [`up.layer.current`](https://unpoly.com/api/up.layer.current.md) will be the background layer during compilation.

---

## Features {#features}

- ### [up.Layer.prototype.accept([value], [options])](https://unpoly.com/api/up.Layer.prototype.accept.md) (Instance method)

  Closes this overlay with an accepting intent, e.g. when a change was confirmed or when a value was selected.

- ### [up.Layer.prototype.affix(selector, [attrs])](https://unpoly.com/api/up.Layer.prototype.affix.md) (Instance method) (experimental)

  Creates an element with the given `selector` and appends it to this layer's content.

- ### [up.Layer.prototype.align](https://unpoly.com/api/up.Layer.prototype.align.md) (Property)

  The alignment of this popup overlay.

- ### [up.Layer.prototype.ancestors](https://unpoly.com/api/up.Layer.prototype.ancestors.md) (Property)

  Returns an array of this layer's ancestor layers.

- ### [up.Layer.prototype.asCurrent(fn)](https://unpoly.com/api/up.Layer.prototype.asCurrent.md) (Instance method)

  Temporarily changes the current layer while the given function is running.

- ### [up.Layer.prototype.child](https://unpoly.com/api/up.Layer.prototype.child.md) (Property)

  Returns this layer's child layer.

- ### [up.Layer.prototype.contains(element)](https://unpoly.com/api/up.Layer.prototype.contains.md) (Instance method)

  Returns whether the given `element` is contained by this layer.

- ### [up.Layer.prototype.context](https://unpoly.com/api/up.Layer.prototype.context.md) (Property) (experimental)

  This layer's context.

- ### [up.Layer.prototype.descendants](https://unpoly.com/api/up.Layer.prototype.descendants.md) (Property)

  Returns an array of this layer's descendant layers, with the closest descendants listed first.

- ### [up.Layer.prototype.dismiss([value], [options])](https://unpoly.com/api/up.Layer.prototype.dismiss.md) (Instance method)

  Closes this overlay _without_ an accepting intent, e.g. when a "Cancel" button was clicked.

- ### [up.Layer.prototype.element](https://unpoly.com/api/up.Layer.prototype.element.md) (Property)

  This layer's outmost container element.

- ### [up.Layer.prototype.emit(eventType, [props])](https://unpoly.com/api/up.Layer.prototype.emit.md) (Instance method)

  Emits an event on this layer's element.

- ### [up.Layer.prototype.history](https://unpoly.com/api/up.Layer.prototype.history.md) (Property)

  Whether this layer has visible history.

- ### [up.Layer.prototype.index](https://unpoly.com/api/up.Layer.prototype.index.md) (Property)

  Returns the zero-based position of this layer in the layer stack.

- ### [up.Layer.prototype.isAlive()](https://unpoly.com/api/up.Layer.prototype.isAlive.md) (Instance method)

  Returns whether this layer is part of the layer stack and can be interacted with.

- ### [up.Layer.prototype.isClosed()](https://unpoly.com/api/up.Layer.prototype.isClosed.md) (Instance method) (deprecated)

  Returns whether this layer is no longer part of the layer stack.

- ### [up.Layer.prototype.isCurrent()](https://unpoly.com/api/up.Layer.prototype.isCurrent.md) (Instance method)

  Returns whether this layer is the current layer.

- ### [up.Layer.prototype.isFront()](https://unpoly.com/api/up.Layer.prototype.isFront.md) (Instance method)

  Returns whether this layer is the frontmost layer.

- ### [up.Layer.prototype.isOpen()](https://unpoly.com/api/up.Layer.prototype.isOpen.md) (Instance method) (deprecated)

  Returns whether this layer is still part of the layer stack.

- ### [up.Layer.prototype.isOverlay()](https://unpoly.com/api/up.Layer.prototype.isOverlay.md) (Instance method)

  Returns whether this layer is _not_ the root layer.

- ### [up.Layer.prototype.isRoot()](https://unpoly.com/api/up.Layer.prototype.isRoot.md) (Instance method)

  Returns whether this layer is the root layer.

- ### [up.Layer.prototype.location](https://unpoly.com/api/up.Layer.prototype.location.md) (Property) (experimental)

  This layer's location URL.

- ### [up.Layer.prototype.mode](https://unpoly.com/api/up.Layer.prototype.mode.md) (Property)

  This layer's mode which governs its appearance and behavior.

- ### [up.Layer.prototype.off(types, listener)](https://unpoly.com/api/up.Layer.prototype.off.md) (Instance method)

  Unbinds an event listener previously bound with `up.Layer#on()`.

- ### [up.Layer.prototype.on(types, [selector], [options], listener)](https://unpoly.com/api/up.Layer.prototype.on.md) (Instance method)

  Listens to a DOM event that originated on an element contained by this layer.

- ### [up.Layer.prototype.origin](https://unpoly.com/api/up.Layer.prototype.origin.md) (Property)

  The button or link that opened this overlay.

- ### [up.Layer.prototype.parent](https://unpoly.com/api/up.Layer.prototype.parent.md) (Property)

  Returns this layer's parent layer.

- ### [up.Layer.prototype.peel([options])](https://unpoly.com/api/up.Layer.prototype.peel.md) (Instance method)

  Dismisses all descendant overlays, making this layer the frontmost layer in the layer stack.

- ### [up.Layer.prototype.position](https://unpoly.com/api/up.Layer.prototype.position.md) (Property)

  The position of this popup or drawer overlay.

- ### [up.Layer.prototype.size](https://unpoly.com/api/up.Layer.prototype.size.md) (Property)

  The size of this overlay.

- ### [up.Layer.prototype.subtree](https://unpoly.com/api/up.Layer.prototype.subtree.md) (Property) (experimental)

  Returns an array of this layer and its descendant layers, with the closest descendants listed first.

- ### [up.Layer.prototype.sync()](https://unpoly.com/api/up.Layer.prototype.sync.md) (Instance method) (experimental)

  Synchronizes this layer with the rest of the page.

- ### [up.Layer.prototype.title](https://unpoly.com/api/up.Layer.prototype.title.md) (Property) (experimental)

  This layer's window title.

