---
title: Address Template
product: Survey Creator
description: Explore our free Address Component demo for JavaScript that shows how to integrate of a pre-designed address template with multiple input fields into your non-cloud SurveyJS form builder. Help users save time and simplify form creation.
framework: React
source: https://surveyjs.io/survey-creator/examples/add-address-to-form-template/reactjs
index: https://surveyjs.io/survey-creator/examples/overview.md
---

# Address Template (React)

The Address template is a reusable question that survey authors can add to their forms to ask respondents for an address. To implement this question in your application, you need to 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: "address",
    title: "Address",
    defaultQuestionTitle: "Enter your address:",
    elementsJSON: [{
        "type": "text",
        "name": "addressLine1",
        "title": "Address",
        "placeholder": "495 Grove Street"
    }, {
        "type": "text",
        "name": "addressLine2",
        "title": "Address line 2",
        "placeholder": "Apartment #20"
    }, {
        "type": "text",
        "name": "city",
        "title": "City/Town",
        "placeholder": "New York"
    }, {
        "type": "text",
        "name": "state",
        "startWithNewLine": false,
        "title": "State/Region/Province",
        "placeholder": "NY"
    }, {
        "type": "text",
        "name": "postCode",
        "title": "Zip/Postal code",
        "inputType": "number",
        "min": 501,
        "max": 14925,
        "placeholder": "10014",
        "startWithNewLine": false
    }, {
        "type": "dropdown",
        "name": "country",
        "title": "Country",
        "placeholder": "USA",
        "choicesByUrl": {
            "url": "https://surveyjs.io/api/CountriesExample",
        }
    }]
});
function SurveyCreatorRenderComponent() {
    const creator = new SurveyCreator();
    creator.toolbox.defineCategories([{
        category: "Custom Items",
        items: [
            "address"
        ]
    }], true);
    
    creator.JSON = {
      elements: [{
        type: "address",
        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-address-to-form-template/angular.md)
- [Vue 3](https://surveyjs.io/survey-creator/examples/add-address-to-form-template/vue3js.md)
- [jQuery](https://surveyjs.io/survey-creator/examples/add-address-to-form-template/jquery.md)
- [Vanilla JS](https://surveyjs.io/survey-creator/examples/add-address-to-form-template/vanillajs.md)
