---
name: "up.layer.accept"
area: "API"
kind: "JavaScript function"
parent: "up.layer module"
url: "https://unpoly.com/api/up.layer.accept"
---
<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.accept([value], [options])

[Accepts](https://unpoly.com/learn/closing-overlays.md) the [current layer](https://unpoly.com/api/up.layer.current.md).

This is a shortcut for `up.layer.current.accept()`. See [`up.Layer#accept()`](https://unpoly.com/api/up.Layer.prototype.accept.md) for more documentation.

<nav aria-label="Guides">

- [Learn: Closing overlays](https://unpoly.com/learn/closing-overlays.md)

</nav>

---

## Parameters {#parameters}

### Acceptance {#parameters-acceptance}

#### [value] {#value}

(optional)

The [acceptance value](https://unpoly.com/learn/closing-overlays.md#acceptance-values) that will be passed to `{ onAccepted }` callbacks.

If there isn't an acceptance value, omit this argument. If you need to pass options without an acceptance value, pass `null`:

```js
up.layer.accept(null, { animation: 'move-to-bottom' })
```

Type: any

#### [options.confirm] {#options.confirm}

(optional)

A message the user needs to confirm before the overlay is closed.

See [Confirmation dialogs: Confirming before closing an overlay](https://unpoly.com/learn/confirmation-dialogs.md#overlays).

Type: string

#### [options.response] {#options.response}

(optional)

The server response that caused this overlay to close.

May be left blank if the overlay was not closed in reaction to a server response.

See [Using the discarded response](https://unpoly.com/learn/closing-overlays.md#using-the-discarded-response).

Type: [up.Response](https://unpoly.com/api/up.Response.md)

### Animation {#parameters-animation}

#### [options.animation] {#options.animation}

(optional)

The [animation](https://unpoly.com/api/up.animate.md) to use for closing this layer.

Defaults to the close animation [configured](https://unpoly.com/api/up.layer.config.md) for this layer mode.

Type: string | Function([Element](https://developer.mozilla.org/en-US/docs/Web/API/Element), [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects))

#### [options.duration] {#options.duration}

(optional)

The duration for the close animation in milliseconds.

Type: number

#### [options.easing] {#options.easing}

(optional)

The [timing function](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function) that controls the acceleration of the close animation.

Type: string

#### [options.onFinished] {#options.onFinished}

(optional)

A callback that will run when the elements have been removed from the DOM.

If the layer has a close animation, the callback will run after the animation has finished.

Type: Function

### History {#parameters-history}

#### [options.history=true] (Experimental) {#options.history}

(optional)

Whether to restore the parent layer's [history state](https://unpoly.com/learn/updating-history.md#history-state) in the browser's address bar.

Type: boolean

