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

# up.Layer.prototype.accept([value], [options])

[Closes this overlay](https://unpoly.com/learn/closing-overlays.md) with an accepting intent, e.g. when a change was confirmed or when a value was selected.

To dismiss a layer _without_ an accepting intent, use [`up.Layer#dismiss()`](https://unpoly.com/api/up.Layer.prototype.dismiss.md) instead.

<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

