---
title: Customize Property Editors
product: Survey Creator
description: The Survey Creator library lets you customize property editors to create new custom properties or modify the built-in ones. View a free demo for JavaScript.
framework: React
source: https://surveyjs.io/survey-creator/examples/customize-property-editors/reactjs
index: https://surveyjs.io/survey-creator/examples/overview.md
---

# Customize Property Editors (React)

The Property Grid allows you to register custom property editors and use them for built-in and custom properties. The editors are based on question types from SurveyJS Form Library. For instance, this example shows how to use the [Single-Line Input](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model) question type to implement a text editor [limited to 15 characters](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maxLength). This editor is used for the **Question name** and **Short name** properties.

Each property editor type is a configuration object that specifies at least two functions:

- `getJSON`: `Function`         
Returns the JSON configuration object of an underlying SurveyJS Form Library question. This object can include any properties supported by that question. 

- `fit`: `Function`             
Specifies one or multiple conditions under which the property editor applies. Returns `true` if the editor can be used for the current property or `false` otherwise. In this demo, a custom editor applies when the property's `type` is `"shorttext"`.

To implement a custom editor, define an object with the `getJSON` and `fit` functions and register it in `PropertyGridEditorCollection`. The custom editor will be used for the properties that satisfy the `fit` conditions. Refer to the Code tab for a code example.

## 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 { Serializer } from "survey-core";
import { PropertyGridEditorCollection } from "survey-creator-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

PropertyGridEditorCollection.register({
    // Use this editor for properties with `type: "shorttext"`
    fit: (prop) => {
        return prop.type === "shorttext";
    },
    // Return a question JSON configuration for the property editor
    // (a single-line input editor that is limited to 15 characters)
    getJSON: () => {
        return { type: "text", maxLength: 15 };
    }
});

// Add a custom property that uses the "shorttext" editor
Serializer.addProperty("question", {
    name: "shortname",
    displayName: "Short name",
    type: "shorttext",
    category: "general",
    visibleIndex: 3
});

// Change the editor for the built-in `name` property
Serializer.getProperty("question", "name").type = "shorttext";
function SurveyCreatorRenderComponent() {
    const creator = new SurveyCreator();
    creator.JSON = {
      "elements": [
        {
          "type": "text",
          "name": "question1"  
        }
      ]
    }
    
    setTimeout(() => {
      creator.showSidebar = true;
      creator.selectElement(creator.survey.getQuestionByName("question1"), "shortname" )
    }, 10);
    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/customize-property-editors/angular.md)
- [Vue 3](https://surveyjs.io/survey-creator/examples/customize-property-editors/vue3js.md)
- [jQuery](https://surveyjs.io/survey-creator/examples/customize-property-editors/jquery.md)
- [Vanilla JS](https://surveyjs.io/survey-creator/examples/customize-property-editors/vanillajs.md)
