JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<span>FooFoo barFoo bar baz</span>
<input type="text" />
</div>
<div class="container">
<span>FooFoo barFoo bar bazFooFoo barFoo bar baz bla</span>
<input type="text" />
</div>
CSS
* {
box-sizing: border-box;
}
.container {
width: 300px;
background: snow;
padding: 5px;
position: relative;
overflow: hidden; /*hide the overflow*/
}
span:after {
content: "\00A0" /*just for one no-break space*/
}
input {
width: 100%;
position: absolute; /*without any top/right/bottom/left value*/
border: 2px solid grey;
border-width: 0 0 2px 0;
}
input:focus {
outline: 0;
}