C&C Docs
Log in

cnc-textarea

A multi-line text field. Beyond the native attributes it adds an enter event, so a textarea can submit on a keystroke without you reading key codes.

Quick start

Bind $value. The binding is two-way, so input is only needed when something else has to react to each keystroke.

0 characters

<div x-data="{ note: '' }">
  <cnc-textarea placeholder="Write a note..." rows="4" $value="note"></cnc-textarea>
</div>

Usage guidance

Set a real maxlength whenever the value has a destination with a limit. The default is effectively unlimited, so the field will happily accept text that the write behind it then rejects — and the user finds out after typing rather than while.

Size it for the expected answer. rows is the starting height and the field does not grow, so two rows invites a sentence and eight invites a paragraph; a box much larger than the answer needed reads as a demand for more.

Use enter only for short entries. In a multi-line field, submitting on Enter takes away the newline key, which is a fair trade for a chat message and the wrong one for anything paragraphed. Pair it with cnc-input where the answer is genuinely one line.

← Back to Widgets