Textarea
Textarea takes multi-line text, such as notes or a bio. It accepts every native textarea attribute. For a single line, use Input.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Examples
Disabled
A disabled textarea shows muted colors and blocks editing.
Invalid
Set aria-invalid to show an error border and error focus ring.
With label
Link a Label to the textarea with htmlFor and id.
This example also needs: Label.
Character counter
Keep a character count in local state and link the helper text and count with aria-describedby.
Keep the note short enough for the activity feed.
56 / 160 characters
This example also needs: Label.
Props
Textarea
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "borderless" | "bordered" | null | "bordered" | No description |
Textarea takes multi-line text, such as notes or a bio. It accepts every native textarea attribute. For a single line, use Input.
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/textarea/Textarea.vue components/textarea/index.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
Disabled
A disabled textarea shows muted colors and blocks editing.
Invalid
Set aria-invalid to show an error border and error focus ring.
With label
Link a Label to the textarea with for and id.
This example also needs: Label.
Character counter
Bind the value with v-model and link the helper text and count with aria-describedby.
This example also needs: Label.
Props
Textarea
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | string | No default documented | The starting value when |
modelValue | string | No default documented | The value, for |
variant | "bordered" | "borderless" | null | "bordered" | No description |