0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Auto-expand a textarea as the user types, from its rows up to an optional data-max-rows cap. CSS field-sizing where supported, a JavaScript measuring fallback elsewhere.
Overview
data-grow on a <textarea> makes it grow with its content and shrink back when text is removed. It starts at rows lines and, with data-max-rows, stops growing at that many lines and scrolls. Browsers with field-sizing: content do the sizing in CSS; elsewhere a script measures scrollHeight.
Usage
Unbounded, capped, and combined with a counter
1234567891011121314
<form-field><labelfor="comment">Comment (unlimited growth)</label><textareaid="comment"name="comment"data-growrows="2"></textarea></form-field><form-field><labelfor="message">Message (max 8 rows)</label><textareaid="message"name="message"data-growrows="2"data-max-rows="8"></textarea></form-field><form-field><labelfor="combined">Combined: grow + character count</label><textareaid="combined"name="combined"data-growdata-countmaxlength="500"rows="2"></textarea></form-field>
With field-sizing (CSS path)
CSS sets field-sizing: content and resize: none on textarea[data-grow], so the textarea grows even before the script runs.
The minimum height is rows lines plus padding and border (field-sizing itself ignores rows, and VB's usual 8rem textarea minimum does not apply).
With data-max-rows, max-block-size is that many lines plus padding and border; past it the textarea scrolls.
The script only writes --grow-rows and --grow-max-rows and marks the textarea data-grow-init="". Programmatic values resize on their own.
Without field-sizing (JavaScript fallback)
The textarea is marked data-grow-init="fallback"; only this path hides overflow and the resize handle.
On input, change and after a form reset, the height is set to auto and then to scrollHeight plus the border, so it shrinks as well as grows.
With data-max-rows the height is capped at that many lines plus padding and border, and overflow-y switches to auto past the cap.
Native attribute. The starting and minimum height in lines; the textarea never shrinks below it.
data-max-rows
positive number
no cap
Lines after which the textarea stops growing and scrolls. 0 or an invalid value means no cap.
data-grow-init
set by the script
—
"" on the CSS path, "fallback" on the JavaScript path. Do not set it yourself. It is not the double-binding guard, so a cloned textarea (which copies it) is still wired.
Events
No custom events. The fallback listens for input and change. Setting .value from script fires neither: with field-sizing the height follows anyway, but for the fallback (and for a data-count counter on the same textarea) dispatch an input event afterwards. Form resets are handled for you.
No public custom properties: --grow-rows and --grow-max-rows are written by the script from rows and data-max-rows; set those attributes instead. The shipped rules:
With field-sizing support the textarea still grows. Its minimum is two lines (the script is what reads rows).
data-max-rows still caps it in browsers that support typed attr(), which read the attribute directly; in others the textarea grows without a cap.
Without field-sizing support it keeps its rows height and the native resize handle.
Accessibility
The native <textarea> is untouched, so labels, keyboard use and screen-reader support are unchanged.
Growing shows all text without an inner scrollbar, which helps users who zoom or have trouble with nested scrolling. Past data-max-rows the textarea scrolls like any other.
The resize handle is removed while the textarea sizes itself; set a generous data-max-rows (or none) so long text stays readable.
data-count — a live character or word counter; combines with data-grow.
<chat-input> — a message composer built on a data-grow textarea with send controls. Choose it for chat-style input; use plain data-grow in ordinary forms.
<form-field> — the label and message wrapper used in the examples.
data-autosave — restored drafts re-measure the textarea.