mutationSignal

G
W

Uses MutationObserver to observe changes to elements passed to the signal. All of the same options that can be passed to a MutationObserver can be passed to this signal.

Like most other signal functions in this library, it can be passed a reference to an element or a signal that returns an element. This makes it convenient to use with Angular's viewChild signal.

Viewing changes to an element's style

To detect when a particular child element is added or removed, pass childList: true. Add subtree: true to also watch nested descendants, as shown below.

Detecting when a child element exists