---
title: Long Text
product: Form Library
description: Get more insights for qualitative research with the open-ended comment question type. It is essentially an open-ended question that provides more space for the respondent to write a longer or more detailed answer. This free demo for JavaScript will show you how to configure and add a comment field to your form.
framework: Vue 3
source: https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/vue3js
index: https://surveyjs.io/form-library/examples/overview.md
---

# Long Text (Vue 3)

A Long Text (or Comment) question is a multi-line text input field that allows users to give detailed responses and share their feelings, experiences, or opinions on a subject. Unlike single- or multi-select questions that offer predefined options, a Long Text question asks respondents to express their thoughts in their own words. This example demonstrates how to create and configure a Long text question. Switch between React, Vue, jQuery, Angular, and Vanilla JS to view the example for your JavaScript framework/library.

## Create a Long Text Question

To create a Long Text form field, define an object with the `type` property set to `"comment"` and add it to the [`elements`](https://surveyjs.io/form-library/documentation/pagemodel#elements) array. Within this object, specify the question's [`title`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#title) and a unique [`name`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#name) that identifies the question. Optionally, you can specify a [`description`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#description) to appear under the `title` and a [`placeholder`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#placeholder) to display within the comment area.

## Resize the Comment Area

The comment area of a Long Text question occupies the height of four rows of text on the screen. If you want to change this number and increase or decrease the height, set the [`rows`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#rows) property.

When the content exceeds the comment area, a vertical scrollbar appears. Enable the [`autoGrow`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#autoGrow) property if you want the comment area to automatically expand or shrink to accommodate the content and thus remove the scrollbar. You can also enable `SurveyModel`'s [`autoGrowComment`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#autoGrowComment) property to activate the same feature for all comment areas in a survey.

A Long Text question displays a resize handle that allows users to resize the comment area. If you want to hide the handle, disable the [`allowResize`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#allowResize) property in an individual Long Text question's configuration or the [`allowResizeComment`](https://surveyjs.io/form-library/documentation/surveymodel#allowResizeComment) in `SurveyModel`. The latter property hides the resize handle for all comment areas.

## Limit the Number of Input Characters

A Long Text form field accepts an unlimited number of characters. If you want to set a limit, use the [`maxLength`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#maxLength) property. With this setting, the comment area displays a character count.

## Files

### `public/index.html`

```html
<div id="app" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; height:100%"></div>
```

### `src/App.vue`

```html
<template>
    <SurveyComponent :model="survey" />
</template>
<script setup lang="ts">
    import { Model } from "survey-core";
    import { SurveyComponent } from "survey-vue3-ui";
    import "survey-core/survey-core.min.css";
    import "./index.css";
    import { json } from "./json";

    const survey = new Model(json);
    survey.onComplete.add((sender, options) => {
        console.log(JSON.stringify(sender.data, null, 3));
    });
</script>
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/json.ts`

```ts
export const json = {
 "pages": [
  {
   "name": "page1",
   "elements": [
    {
      "type": "comment",
      "name": "suggestions-auto-grow",
      "title": "What would make you more satisfied with our product?",
      "description": "The comment area has an initial height of two rows and automatically expands or shrinks to accomodate the content.",
      "rows": 2,
      "autoGrow": true,
      "allowResize": false
    },
    {
      "type": "comment",
      "name": "suggestions-max-length",
      "title": "What would make you more satisfied with our product?",
      "description": "The comment area is resizable and limited to 500 characters.",
      "maxLength": 500
    }
   ]
  }
 ]
};
```

### `src/main.ts`

```ts
import { createApp } from "vue";
import App from "./App.vue";

const app = createApp(App);
app.mount("#app");
```

### `src/shims-vue.d.ts`

```ts
/* eslint-disable */
declare module "*.vue" {
    import type { DefineComponent } from "vue"
    const component: DefineComponent<{}, {}, any>
    export default component
}
```

### `src/theme.ts`

```ts
export const themeJson = {};
```

### `.eslintrc.js`

```js
module.exports = {
    root: true,
    env: {
        node: true
    },
    extends: [
        "plugin:vue/vue3-essential",
        "eslint:recommended",
        "@vue/typescript/recommended",
        "@vue/prettier",
        "@vue/prettier/@typescript-eslint"
    ],
    parserOptions: {
        ecmaVersion: 2020
    },
    rules: {
        "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
        "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
    },
    overrides: [
        {
            files: [
                "**/__tests__/*.{j,t}s?(x)",
                "**/tests/unit/**/*.spec.{j,t}s?(x)"
            ],
            env: {
                jest: true
            }
        }
    ]
};
```

### `babel.config.js`

```js
module.exports = {
  presets: ["@vue/cli-plugin-babel/preset"]
};
```

### `package.json`

```json
{
  "name": "surveyjs-library-vue3",
  "version": "0.1.0",
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "tslib": "2.6.1",
    "vue": "^3.4.1",
    "survey-core": "latest",
    "survey-vue3-ui": "latest",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.33.0",
    "@typescript-eslint/parser": "^2.33.0",
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-pwa": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-typescript": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/eslint-config-typescript": "^5.0.2",
    "@vue/test-utils": "^2.0.0-0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^7.0.0-0",
    "node-sass": "^4.12.0",
    "prettier": "^1.19.1",
    "sass-loader": "^8.0.2",
    "typescript": "~3.9.3"
  }
}
```

### `tsconfig.json`

```json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/angular.md)
- [React](https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/reactjs.md)
- [jQuery](https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/jquery.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/vanillajs.md)
