Getting an element's scrollWidth

Your outer container (div) has a fixed width.
Put the text in a div of its own without a fixed width. This inner div will/should collapse to the width of the text.
Give each div an id.
Using Browser.Dom.getElement id you can measure the width of each div.

If the Html package doesn’t play nicely using this approach, try elm-ui.

If you give the inner div a thin border, you can see if it is collapsing to the text as expected.

Hope this helps.

1 Like