Our take
- Activity
- 31
- Community
- 46
- Issues
- 21
- Pull requests
- 20
+1 stars in the last 30 days
Project history
Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.
Stars
543Forks
10Change since Nov 16, 2026: +1 stars·0 forks
Overview
Style Observer lets JavaScript respond when a CSS property changes on an element. It addresses a gap in browser APIs by detecting changes to both custom and standard properties without polling, using browser mechanisms with workarounds for known bugs.
It is suited to frontend developers who need style changes to trigger application behavior. It is not a general-purpose observer for every CSS change: several properties and animation-driven changes are outside its scope.
Key Features
- Observe custom properties and most standard CSS properties.
- Track multiple properties across multiple elements with one observer.
- Observe elements in Shadow DOM.
- Receive records containing the target, property, new value, and old value.
- Configure throttling so closely spaced changes are delivered together.
- Avoid overwriting existing transitions.
- Provides ESM-only code with no dependencies, according to the README.
Use Cases
- Frontend developers can update JavaScript-driven behavior when a CSS custom property changes.
- Component authors can observe style changes across multiple elements, including components using Shadow DOM.
- Teams that coordinate CSS state and JavaScript behavior can react to property updates without periodic polling.
- Developers can monitor discrete or animatable standard properties when browser support and the documented exclusions fit their needs.
Getting Started
Install from npm:
npm install style-observer
See the README for import options, usage, and compatibility details.
Considerations
- Observation requires elements to be connected to a document. Changes made while disconnected are picked up once the elements are connected again.
- The library cannot observe
transitionoranimationproperties, their constituent properties, or changes caused by CSS animations. - Moving a slotted element to a different slot is not detected.
- If transition properties change after observation starts, call
observer.updateTransition(targets)to regenerate the transition used for detection. - The README documents browser-version requirements that vary by property type. Check its compatibility table before relying on support across target browsers.
- The project reports 542 stars and 11 forks, but those figures alone do not establish suitability for a particular production environment. Review its tests and compatibility guidance for your use case.
Found this useful?
Share it with someone who would like style-observer.