A tight shrink wrapping implementation in modern browsers using progressive enhancement concept, see examples below for visual explanation. Requires scroll-driven animations to work, gracefully ignored in older browsers.
Making sure chat messages only span as wide as they have to.
I'm a short message
I'm a broken long message wrapping to a new line
I'm a fixed long message wrapping to a new line I'm a short message
I'm a broken long message wrapping to a new line
I'm a fixed long message wrapping to a new line
<section
tuiMessage
class="incoming"
>
I'm a short message
</section>
<section
tuiMessage
class="incoming"
>
I'm a broken long message wrapping to a new line
</section>
<section
tuiMessage
tuiShrinkWrap
class="incoming"
>
<tui-shrink-wrap>I'm a fixed long message wrapping to a new line</tui-shrink-wrap>
</section>
<section
tuiMessage
class="outgoing"
>
I'm a short message
</section>
<section
tuiMessage
class="outgoing"
>
I'm a broken long message wrapping to a new line
</section>
<section
tuiMessage
tuiShrinkWrap
class="outgoing"
>
<tui-shrink-wrap>I'm a fixed long message wrapping to a new line</tui-shrink-wrap>
</section>
Toasts already have tuiShrinkWrap directive on host.
With ShrinkWrap
Long messages are wrapping perfectly to fit into max width of the toast
Without ShrinkWrap
Long messages are wrapping perfectly to fit into max width of the toast
<h4 tuiHeader="body-l">With ShrinkWrap</h4>
<div tuiToast>
<tui-shrink-wrap>Long messages are wrapping perfectly to fit into max width of the toast</tui-shrink-wrap>
</div>
<h4 tuiHeader="body-l">Without ShrinkWrap</h4>
<div tuiToast>Long messages are wrapping perfectly to fit into max width of the toast</div>
Any valid CSS size string can be used, including calc , different units, vars and math functions.
TitleLong messages are wrapping perfectly to fit into max width of the cell
<div
tuiCell
tuiShrinkWrap="15rem"
>
<div tuiAvatar="@tui.user"></div>
<div tuiTitle>
<strong>Title</strong>
<tui-shrink-wrap>Long messages are wrapping perfectly to fit into max width of the cell</tui-shrink-wrap>
</div>
</div>