Skip to main content

Textarea ready

Textarea specifies a control that allows user to write text over multiple rows. Used when the expected user input is long. For shorter input, use the Input component.

You can use native HTML5 validation with Textarea component via validation properties. This allows you to specify rules like whether a value needs to be filled in and the minimum and maximum length of the data.

Examples

Open in new window
<duet-textarea expand label="Textarea label" placeholder="Placeholder text" debounce="500"></duet-textarea>

<script>
// Select the above textarea component
var textarea = document.querySelector("duet-textarea")

// Listen for change events. Use debounce prop to adjust the time to trigger this.
textarea.addEventListener("duetChange", function(e) {
console.log("Change detected in textarea:", e.detail)
})
</script>
Open in new window
<duet-textarea disabled expand label="Textarea label" placeholder="Placeholder text" value="Some disabled content"></duet-textarea>
Open in new window
<duet-textarea error="There’s a validation error" expand label="Textarea label" placeholder="Placeholder text" value="Some disabled content"></duet-textarea>

Properties #

Property Attribute Description Type Default
accessibleActiveDescendant accessible-active-descendant Indicates the id of a related component’s visually focused element. string undefined
accessibleAutocomplete accessible-autocomplete Indicates what kind of user input completion suggestions are provided. string undefined
accessibleControls accessible-controls Use this prop to add an aria-controls attribute. Use the attribute to indicate the id of a component controlled by this component. string undefined
accessibleOwns accessible-owns Indicates the id of a component owned by the textarea. string undefined
debounce debounce Set the amount of time, in milliseconds, to wait to trigger the duetChange event after each keystroke. number 0
disabled disabled Makes the textarea component disabled. This prevents users from being able to interact with the textarea, and conveys its inactive state to assistive technologies. boolean false
error error Display the textarea in error state along with an error message. string ""
expand expand Expands the textarea to fill 100% of the container width. boolean false
identifier identifier Adds a unique identifier for the textarea. string undefined
label label Label for the textarea. string "label"
labelHidden label-hidden Visually hide the label, but still show it to screen readers. boolean false
margin margin Controls the margin of the component. Can be one of: "auto", "none". string "auto"
maxlength maxlength Use maxlength to specify the maximum length of the value that can be entered. Please note that this uses native HTML5 pattern validation. number undefined
minlength minlength Use minlength to specify the minimum length of the value that can be entered. Please note that this uses native HTML5 pattern validation. number undefined
name name Name of the textarea. string undefined
placeholder placeholder Hint text to display. string undefined
required required Set whether the textarea is required or not. boolean false
role role Defines a specific role attribute for the input. string undefined
theme theme Theme of the textarea. Can be one of: "default", "turva". string ""
tooltip tooltip Tooltip to display next to the label of the input. string ""
value value Value of the textarea. string undefined

Events #

Event Description Type
duetBlur Emitted when the input loses focus. CustomEvent<any>
duetChange Emitted when the value has changed. CustomEvent<any>
duetFocus Emitted when the input has focus. CustomEvent<any>
duetInput Emitted when a keyboard input ocurred. CustomEvent<any>

Methods #

setFocus() => Promise<void> #

Sets focus on the specified duet-textarea. Use this method instead of the global
textarea.focus().

Returns #

Type: Promise<void>

Dependencies #

Depends on #

Graph #

graph TD;
duet-textarea --> duet-label
duet-textarea --> duet-tooltip
duet-tooltip --> duet-visually-hidden
style duet-textarea fill:#f9f,stroke:#333,stroke-width:4px

Integration

For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.



Tutorials

Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:

Tutorials

Building Layouts

Tutorials

Server Side Rendering


Troubleshooting

If you experience any issues while using a component, please head over to the Support page for more guidelines and help.