Summary of the problem:
I am searching for a method to establish font size values based on an element inside a shadow dom relative to the shadow host, regardless of the parent element's font size within the shadow dom. I am looking for a solution similar to using em-values but with the shadow as the root instead of the HTML root.
The purpose of this is to scale content such as widgets that are inserted with shadow dom in one centralized location. By scaling properties based on font size in this manner, the entire widget can be scaled uniformly without needing to adjust numerous CSS values to fit different contexts.
Detailed description of the issue:
I am seeking a way to size text (font size) based on a specific element in the DOM, allowing for the scaling of different parts of content within that element based on its wrapping element. This functionality extends beyond just text sizing—it also benefits from basing various CSS values on font size to ensure visual layout components scale proportionately with text size changes, such as padding, border radius, and shadows. Relying solely on em-values can become convoluted when dealing with multiple levels of font size inheritance within elements. Adjusting the font-size of the first level without impacting subsequent levels requires manipulating individual em values throughout the DOM structure, which is not ideal in many cases.
An effective alternative is leveraging Root EM (rem) units so that altering one DOM level does not impact sub-elements. However, if I wish to increase or decrease the text size within a specific wrapping element without affecting other page elements, it becomes necessary to adjust rem-values for all font sizes within elements contained within that wrapping element.
...