Is it possible to construct a box whose maximum width is specified, but in situations where that width is wider than the remaining width in a line, then the box just uses whatever space is left?
My use case is a book with fill-in-the-blanks. Each fill-in-the-blank has a width attached to it, like say 15em. It's great if the fill-in-the-blank is printed as a 15em wide box. But sometimes the fill-in-the-blank comes near the end of the line, and runs into the margin. I'd prefer it to just terminate as a shorter box. (And I'd prefer this over any kind of wrapping.)
With my use case in mind, here is something like what I am after in a sort of pseudo syntax: \framebox[min(15em, width of an hfill)]{\strut}
.