JSFiddle - React, Tailwind, and code Playground

HTML

<div></div>

JavaScript

// Sample string, to make it easy to see the cut points I've use 1-15 in hex to give us a nice easy way to see the breaks
var string = "1234567 9ABCDE 12345 7 89AB 123456 89ABC E 12 45 789A CD 123";

var parts = string.split(' ');
var sections = [""];
var rows = 0;
for (var i = 0; i < parts.length; ++i) {
    if (sections[rows].length + parts[i].length + 1 > 15) {
        rows++;
    }
    if(!sections[rows]) {
        sections[rows] = parts[i];
    } else {
        sections[rows] += " " + parts[i];
    }
}

$('div').html(sections.join("<br />"));