Get the actual size of a Lit component

Hello, I am trying to use a Lit component which contains multiple canvas elements (which are added in the frontend typescript code). These canvas elements need a fixed size. When I use functions like parentElement.offsetWidth or clientWidth i get wrong values. Is there another way to retrieve the actual size of the element?

The custom element is added in the Java code to a FlexLayout

getBoundingClientRect() from the Lit component itself returns 0,0 and from the parent (the flex layout) the same width and height like offsetWidth and offsetHeight

and these values are larger than the actual width and height of the layout which is rendered in the browser

Well you have to calculate it :wink: and it’s working at least on the client side if you are doing it inside the lit element

how should I calculate it?

Nevermind, I found the problem. Before, my Lit Component extended Component… I extended it now with a Div and called setSizeFull()… now the values are right