layerchart icon indicating copy to clipboard operation
layerchart copied to clipboard

Add `TextRect` component to easily add backgrounds to `Text` components

Open techniq opened this issue 8 months ago • 1 comments

Would be very helpful when using Svg and Canvas layers to easily add a Rect as a background behind a Text. Getting the dimensions (and support a padding attribute) will take some thought.

This could also be directly integrated into Text as:

<Text background="...">, <Text bg="...">, etc

techniq avatar Apr 30 '25 21:04 techniq

Since we already get word/line width in Text we should able able to leverage this to create the width of the bounding box.

Currently getStringWidth() uses getComputedTextLength() but might be better to get the bounding box with one of the aforementioned.

See also this canvas StackOverflow answer and SVG example

techniq avatar May 20 '25 18:05 techniq