Cart Licenses Contact Support Online Creator Log in/Register
Try
Buy
v 1.9.50

Survey Creator Toolbox Customization


                        



const options = { questionTypes : ["text", "checkbox", "radiogroup", "dropdown"] };            
                var creator = new SurveyCreator.SurveyCreator(options);
            
                
                    ReactDOM.render(
                    <React.StrictMode>
                        <SurveyCreator.SurveyCreatorComponent creator={creator} />
                    </React.StrictMode>,
                    document.getElementById("creatorElement")
                    );
                
// Disable the compact display mode
creator.toolbox.forceCompact = false;
// Change the title of the Text question type
creator.toolbox.getItemByName("text").title = "Single-Line Text";
// Change the icon of the Checkbox question type
creator.toolbox.getItemByName("checkbox").iconName = "icon-checked";

// Specify new default choices
const newDefaultChoices = [
  { text: "Option 1", value: 1 },
  { text: "Option 2", value: 2 },
  { text: "Option 3", value: 3 }
];

// Apply the default choices to the Checkbox, Radiogroup, and Dropdown question types
creator.toolbox.getItemByName("checkbox").json.choices = newDefaultChoices;
creator.toolbox.getItemByName("radiogroup").json.choices = newDefaultChoices;
creator.toolbox.getItemByName("dropdown").json.choices = newDefaultChoices;
                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Survey Toolbox customization, Reactjs Example | Free Form Builder</title>
    
<meta name="viewport" content="width=device-width" />
    <script src="https://unpkg.com/react@17.0.1/umd/react.production.min.js"></script>
    <script src="https://unpkg.com/react-dom@17.0.1/umd/react-dom.production.min.js"></script>
    <script src="https://unpkg.com/@babel/standalone@7.2.5/babel.min.js"></script>
    <script src="/DevBuilds/survey-core/survey.core.min.js"></script>
    <script src="/DevBuilds/survey-core/survey.i18n.min.js"></script>
    <script src="/DevBuilds/survey-react-ui/survey-react-ui.min.js"></script>
    <link href="/DevBuilds/survey-core/defaultV2.min.css" type="text/css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ace.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.10/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
    <!-- Uncomment to enable Select2
    <script src="https://unpkg.com/jquery"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
    -->
        <script src="/DevBuilds/survey-creator-core/survey-creator-core.min.js"></script>
        <link href="/DevBuilds/survey-creator-core/survey-creator-core.min.css" type="text/css" rel="stylesheet" />
        <script src="/DevBuilds/survey-creator-core/survey-creator-core.i18n.min.js"></script>
        <script src="/DevBuilds/survey-creator-react/survey-creator-react.min.js"></script>
        <style>
            :root {
                --tab-min-height: 600px;
            }
        </style>
    <link rel="stylesheet" href="./index.css">

</head>
<body style="margin: 0">
    
<div id="surveyContainer">
            <div id="creatorElement" style="height: 100vh;"></div>
</div>

<script type="text/babel" src="./index.js"></script>

</body>
</html>

The Toolbox contains available question and panel types. Click one of these survey elements or drag and drop it onto the design surface to add the element to the survey. This demo shows how to customize the Toolbox and its items.

Full and Compact Modes

The Toolbox supports full and compact modes. In compact mode, element names are hidden and become visible only when users move the mouse pointer over the element icon.

The Toolbox switches between the modes automatically based on the width of Survey Creator. Specify the forceCompact property if you want the Toolbox to always use a specific mode. This demo disables the forceCompact property to always show the Toolbox in full mode.

Limit Available Question and Panel Types

All available question and panel types are listed in the getType() method description. If you need to show only a part of these types, specify them in the Survey Creator's questionTypes array. In this demo, the array limits available question types to Text, Checkbox, Radiogroup, and Dropdown.

Customize Predefined Toolbox Items

To customize a predefined Toolbox item, pass its type as an argument to the getItemByName(itemName) method. This method returns the item's configuration object. Change the properties of this object to customize the Toolbox item. For example, this demo shows how to change the title for the Text question, the iconName for the Checkbox question, and the json schema for multiple questions.

Add a Custom Toolbox Item

Since the Toolbox is meant to contain question and panel types, to add a new element, you need to create a custom question or panel type. Refer to the following help topic for detailed instructions: