[csswg-drafts] [css-ui] ? Allow <textarea> to be sized by contents. (#7542)

bfgeek has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-ui] ? Allow <textarea> to be sized by contents. ==
See: https://github.com/whatwg/html/issues/6807 for more context about the problem we'd like to solve. The TL;DR is that we'd like to allow the `<textarea>` element to be sized to its contents a little easier. I.e.

![textarea-1](https://user-images.githubusercontent.com/992712/166292770-8659fed3-4717-4d65-a0ad-80ce4c9b7e25.gif)

We explored different solutions in the whatwg thread. Folks seem to prefer a CSS solution to this problem - hence this issue!

One way to achieve the "minrows"/"maxrows" in that issue is to use the "lh" unit. (Fortunately the "lh" unit works exactly the same way textareas are implemented today - in that they use the first available font to calculate the line-height).

E.g. 
```
textarea {
  min-height: 2lh;
  max-height: 5lh;
}
```

The only thing we are missing is the ability to use the "actual"[1] intrinsic size of the textarea. There are a few different potential solutions here.

Today the intrinsic-size of a textarea will (roughly) read the "rows" attribute, and multiply this by the "lh" unit. We need a switch to instead read the "rows" attribute to be based on the actual number of lines. One potential solution is:

`textarea-rows: auto | <number>`

If "auto" was set the user-agent would read the number of lines, then multiply this by "lh" to get the intrinsic block-size for the text-area.

We could then map the rows attribute to a presentation style hint to this property.

cc/ @tabatkins @lilles 

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7542 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 28 July 2022 23:13:19 UTC