:xr-overlay CSS pseudo-class

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The :xr-overlay CSS pseudo-class matches the DOM overlay element when a web page is being viewed in an immersive AR or VR environment.

Syntax

css
:xr-overlay {
  /* ... */
}

Description

The :xr-overlay pseudo-class matches the overlay element for the duration of an immersive session using a DOM overlay.

The overlay element is a backdrop root. Any backdrop-filter effects on the DOM overlay element or its descendants do not modify the AR camera image (if applicable) or the rendered content drawn to the immersive session's XRWebGLLayer.

The overlay element itself is a stacking context due to its fixed position. The stacking contexts for ancestors of the overlay element, if any, do not paint to the immersive session's display.

Note: On a multi-display system, the stacking contexts for ancestors or sibling trees of the overlay element may be displayed on separate displays.

Examples

Basic usage

In this example, we define the overlay to be semi-transparent black, enabling content behind the overlay to be partially visible. To ensure enough contrast between content and its background, we set the color to white.

css
:xr-overlay {
  background-color: rgba(0 0 0 / 0.5);
  color: white;
}

Specifications

Specification
WebXR DOM Overlays Module
# selectordef-xr-overlay

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
:xr-overlay
Experimental
Chrome – Full support
Chrome 83 (Release date: 2020-05-19)
footnote Full support
Edge – Full support
Edge 83 (Release date: 2020-05-21)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 69 (Release date: 2020-06-24)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 83 (Release date: 2020-05-19)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 59 (Release date: 2020-06-30)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 13 (Release date: 2020-12-02)
footnote Full support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

See also