---
title: Full Name Template
product: Survey Creator
description: Choose from a collection of free ready-made templates of most common web form sections, e.g., contact information or shipping details. The elements ship with predefined properties for easy and fast integration into your JavaScript app.
framework: React
source: https://surveyjs.io/survey-creator/examples/add-full-name-to-form-template/reactjs
index: https://surveyjs.io/survey-creator/examples/overview.md
---

# Full Name Template (React)

The Full Name question asks a respondent to enter their first, last, and optionally middle name. To implement this question in your application, create a composite question type.

[Create Composite Question Types](https://surveyjs.io/form-library/documentation/customize-question-types/create-composite-question-types (linkStyle))

## Files

### `public/index.html`

```html
<!-- Uncomment the following lines to enable Ace Editor in the JSON Editor tab -->
<!-- 
<script src="https://unpkg.com/ace-builds/src-min-noconflict/ace.js"></script>
<script src="https://unpkg.com/ace-builds/src-min-noconflict/ext-searchbox.js"></script>
<script src="https://unpkg.com/ace-builds/src-min-noconflict/theme-clouds_midnight.js"></script>
-->

<div id="surveyCreatorContainer" style="position: absolute; height: 100%; width: 100%"></div>
```

### `src/SurveyCreatorComponent.jsx`

```js
import React from "react";
import { SurveyCreator, SurveyCreatorComponent } from "survey-creator-react";
import "survey-core/survey.i18n";
import "survey-creator-core/survey-creator-core.i18n";
import { ComponentCollection, Serializer } from "survey-core";
import "survey-core/survey-core.css";
import "survey-creator-core/survey-creator-core.css";
import "./index.css";

import SurveyTheme from "survey-core/themes";
import { registerCreatorTheme } from "survey-creator-core";

registerCreatorTheme(SurveyTheme); // Add predefined Survey Creator UI themes

ComponentCollection.Instance.add({
    name: "fullname", 
    title: "Full Name", 
    defaultQuestionTitle: "Enter your full name:",
    elementsJSON: [{
        type: "text",
        name: "firstName",
        title: "First Name"
    }, {
        type: "text",
        name: "middleName",
        title: "Middle Name",
        visible: false
    }, {
        type: "text",
        name: "lastName",
        title: "Last Name"
    }],
    onInit() {
        // Add a `showMiddleName` Boolean property to the `fullname` question type
        Serializer.addProperty("fullname", {
            name: "showMiddleName",
            type: "boolean",
            default: false,
            category: "general",
        });
    },
    onLoaded (question) {
        question.panelWrapper.questionTitleLocation = "left";
        question.panelWrapper.questionTitleWidth = 120;
        // Set the Middle Name question visibility at startup
        this.changeMiddleNameVisibility(question);
    },
    // Track the changes of the `showMiddleName` property
    onPropertyChanged (question, propertyName) {
        if (propertyName === "showMiddleName") {
            this.changeMiddleNameVisibility(question);
        }
    },
    changeMiddleNameVisibility (question) {
        const middleName = question.contentPanel.getQuestionByName("middleName");
        if (!!middleName) {
            // Set the `middleName` question's visibility based on the composite question's `showMiddleName` property 
            middleName.visible = question.showMiddleName;
        }
    },
  });
function SurveyCreatorRenderComponent() {
    const creator = new SurveyCreator();
    creator.toolbox.defineCategories([{
        category: "Custom Items",
        items: [
            "fullname"
        ]
    }], true);
    
    creator.JSON = {
      elements: [{
          type: "fullname",
          name: "question1"
      }]
    };
    return (<SurveyCreatorComponent creator={creator} />);
}

export default SurveyCreatorRenderComponent;
```

### `src/index.css`

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

### `src/index.js`

```js
import React from "react";
import { createRoot } from "react-dom/client";
import SurveyCreatorRenderComponent from "./SurveyCreatorComponent";

const root = createRoot(document.getElementById("surveyCreatorContainer"));
root.render(<SurveyCreatorRenderComponent />);
```

### `package.json`

```json
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "survey-core": "latest",
    "survey-react-ui": "latest",
    "survey-creator-core": "latest",
    "survey-creator-react": "latest"
  },
  "devDependencies": {
    "react-scripts": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/survey-creator/examples/add-full-name-to-form-template/angular.md)
- [Vue 3](https://surveyjs.io/survey-creator/examples/add-full-name-to-form-template/vue3js.md)
- [jQuery](https://surveyjs.io/survey-creator/examples/add-full-name-to-form-template/jquery.md)
- [Vanilla JS](https://surveyjs.io/survey-creator/examples/add-full-name-to-form-template/vanillajs.md)
