In the future you will be able to use field-sizing
CSS property [MDN field-sizing]. Currently (end of the year 2024) it is experimental feature with limited availability [caniuse]
Currently, you can test in on chromium based browsers
textarea {
field-sizing: content;
}