Favorites

DOM CustomEvent.detail Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
CustomEvent.detail
DOM CustomEvent PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

The detail property of a CustomEvent holds the data passed when the event was created.

Description

The read-only detail property returns the data passed in the detail option of the CustomEvent constructor. It can be any value, typically an object, and it's how custom events carry information to their listeners.

Since the same object is passed to every listener, any listener can read it, and changes made to it are visible to listeners that run later and to the code that dispatched the event. That can be used deliberately to collect responses, but it's usually clearer to keep detail read-only.

If no detail option is given, it's null. Regular Event objects don't have a detail property; it's specific to CustomEvent and a few built-in events, such as clicks, where it holds the click count.

Syntax

event.detail

Value

Any value given in the detail option when the event was created.

Example

document.addEventListener('user:login', e => console.log('Welcome,', e.detail.name, '- role:', e.detail.role));
document.dispatchEvent(new CustomEvent('user:login', { detail: { name: 'Sam', role: 'editor' } }));

Browser Support

The following information will show you the current browser support for the CustomEvent.detail property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee