user6386155
user6386155

Reputation: 857

Programmatically determine the html background color

Is there a way to determine the background color used in the html, from inside an angular component? I am writing an angular component that's inside one of the many feature modules used where I need to know the background color used by the page, and I would like to determine dynamically the background color utilized. The webpage has multiple tabs, and this component can appear in any tab

Upvotes: 0

Views: 84

Answers (1)

Eli Porush
Eli Porush

Reputation: 1567

try this:

getComputedStyle(document?.querySelector?.("body") as Element).backgroundColor

Upvotes: 1

Related Questions