Textarea
Thymeleaf source
<sl:label for="message">Message</sl:label><sl:textarea th:field="*{message}" placeholder="Type your message here."/>Rendered HTML
<label class="label" for="message">Message</label><textarea class="textarea" id="message" name="message" placeholder="Type your message here."></textarea>The textarea grows with its content in browsers that support field-sizing; elsewhere it keeps its height and
scrolls. rows sets a starting height.
Initial text
Section titled “Initial text”With th:field, Spring fills the textarea from the field. Without it, the component’s content is the initial text:
Thymeleaf source
<sl:label for="textarea-notes">Notes</sl:label><sl:textarea id="textarea-notes" name="notes">Leave the parcel at the back door.</sl:textarea>Rendered HTML
<label class="label" for="textarea-notes">Notes</label><textarea class="textarea" id="textarea-notes" name="notes">Leave the parcel at the back door.</textarea>Invalid
Section titled “Invalid”As with the input, a field with errors marks the textarea aria-invalid="true".
Thymeleaf source
<sl:label for="message">Message</sl:label><sl:textarea th:field="*{message}"/>Rendered HTML
<label class="label" for="textarea-invalid">Message</label><textarea class="textarea" id="textarea-invalid" name="message" aria-invalid="true"></textarea>Disabled
Section titled “Disabled”As the input: faded, not focusable and not submitted; lyra adds a grey background.
Thymeleaf source
<sl:label for="textarea-disabled">Message</sl:label><sl:textarea id="textarea-disabled" name="message" disabled/>Rendered HTML
<label class="label" for="textarea-disabled">Message</label><textarea class="textarea" id="textarea-disabled" name="message" disabled></textarea>Read-only
Section titled “Read-only”As the input: a muted background and full text colour; it takes focus and is submitted.
Thymeleaf source
<sl:label for="textarea-instructions">Delivery instructions</sl:label><sl:textarea id="textarea-instructions" name="instructions" readonly>Leave the parcel with the neighbours at number 12.</sl:textarea>Rendered HTML
<label class="label" for="textarea-instructions">Delivery instructions</label><textarea class="textarea" id="textarea-instructions" name="instructions" readonly>Leave the parcel with the neighbours at number 12.</textarea>Attributes
Section titled “Attributes”sl:textarea declares no props; every attribute passes through.