---
title: Manage Toolbox Subitems
product: Survey Creator
description: Easily add and remove nested toolbox items that help you create more specific configurations of a broader survey element type and group them. View a free demo example for JavaScript to learn more.
framework: React
source: https://surveyjs.io/survey-creator/examples/manage-toolbox-subitems/reactjs
index: https://surveyjs.io/survey-creator/examples/overview.md
---

# Manage Toolbox Subitems (React)

Toolbox items can have nested items, or "subitems". They appear when users hover over a toolbox item. Subitems help you create more specific configurations of a broader survey element type and group them. For example, the Single-Line Input toolbox item includes a number of subitems that create Single-Line Input questions with different "Input type" property values. **Hover over** the Single-Line Input toolbox item to view these subitems. This demo shows how to add a custom toolbox subitem and explains how to manage built-in subitems. For demonstration purposes, available toolbox items are limited to those that have subitems.

> Subitems are unavailable in a [compact toolbox](/survey-creator/documentation/toolbox-customization#full-and-compact-modes).

To create a custom subitem, pass its [configuration object](/survey-creator/documentation/api-reference/iquestiontoolboxitem) to the [`addSubitem(subitem, index)`](/survey-creator/documentation/api-reference/iquestiontoolboxitem#addSubitem) method. Call this method on a toolbox item instance to which you want to add the subitem. For instance, the following code adds a "Limited to 280 characters" subitem to the Long Text toolbox item:

```js
const longTextItem = creator.toolbox.getItemByName("comment");
longTextItem.addSubitem({
    name: "limitedLongText",
    title: "Limited to 280 characters",
    json: {
        type: "comment",
        maxLength: 280
    }
});
```

If you want to remove a specific subitem, call the [`removeSubitem(subitem)`](/survey-creator/documentation/api-reference/iquestiontoolboxitem#removeSubitem) method on a toolbox item instance. The following list contains the predefined subitems available by default:

- [Rating Scale](/form-library/examples/rating-scale/): `"labels"`, `"stars"`, `"smileys"`
- [Single Line-Input](/form-library/examples/text-entry-question/): `"color"`, `"date"`, `"datetime-local"`, `"email"`, `"month"`, `"number"`, `"password"`, `"range"`, `"tel"`, `"text"`, `"time"`, `"url"`, `"week"`

```js
// Remove the Labels subitem from the Rating Scale toolbox item
const ratingScaleItem = creator.toolbox.getItemByName("rating");
ratingScaleItem.removeSubitem("labels");
```

You can also remove all subitems from a toolbox item by calling the [`clearSubitems()`](/survey-creator/documentation/api-reference/iquestiontoolboxitem#clearSubitems) method:

```js
// Remove all subitems from the Single-Line Input toolbox item
const singleLineInputItem = creator.toolbox.getItemByName("text");
singleLineInputItem.clearSubitems();
```

> Toolbox subitems act like shortcuts for creating certain question configurations. Removing a subitem doesn't remove the associated properties from the Property Grid. If you need to prevent users from editing them, [hide those properties explicitly](/survey-creator/documentation/property-grid-customization#hide-properties-from-the-property-grid).

You can completely deactivate the subitems feature by disabling the Toolbox's [`showSubitems`](/survey-creator/documentation/api-reference/questiontoolbox#showSubitems) property:

```js
creator.toolbox.showSubitems = false;
```

## 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 "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

function SurveyCreatorRenderComponent() {
    const creator = new SurveyCreator({ questionTypes: [ "text", "rating", "comment", "paneldynamic" ] });
    // Do not categorize toolbox items since there are only four of them
    creator.toolbox.removeCategories();
    
    // Add a custom subitem to the Long Text toolbox item
    const longTextItem = creator.toolbox.getItemByName("comment");
    longTextItem.addSubitem({
        name: "limitedLongText",
        title: "Limited to 280 characters",
        json: {
            type: "comment",
            maxLength: 280
        }
    });
    
    // Add custom subitems to the Dynamic Panel toolbox item
    const dynamicPanelItem = creator.toolbox.getItemByName("paneldynamic");
    dynamicPanelItem.addSubitem({
        name: "tabbedDynamicPanel",
        title: "Tabbed UI",
        json: {
            type: "paneldynamic",
            displayMode: "tab"
        }
    });
    dynamicPanelItem.addSubitem({
        name: "carouselDynamicPanel",
        title: "Carousel UI",
        json: {
            type: "paneldynamic",
            displayMode: "carousel"
        }
    });
    
    // Add custom subitems to the Rating Scale toolbox item
    const ratingItem = creator.toolbox.getItemByName("rating");
    ratingItem.addSubitem({
        name: "csat",
        title: "Customer Satisfaction Score",
        json: { 
            "type": "rating",  
            "rateType": "smileys", 
            "rateCount": 5, 
            "title": "How satisfied are you with our product?",
            "minRateDescription": "Very unsatisfied",
            "maxRateDescription": "Very satisfied"
        }
    });
    
    ratingItem.addSubitem({
        name: "nps",
        title: "Net Promoter Score",
        json:  { 
            "type": "rating", 
            "title": "How likely are you to recommend our product to a friend or colleague?", 
            "rateMin": 0, 
            "rateMax": 10 
        }
    });
    
    // Disable the compact toolbox because subitems are available only in full toolbox view 
    creator.toolbox.forceCompact = false;
    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/manage-toolbox-subitems/angular.md)
- [Vue 3](https://surveyjs.io/survey-creator/examples/manage-toolbox-subitems/vue3js.md)
- [jQuery](https://surveyjs.io/survey-creator/examples/manage-toolbox-subitems/jquery.md)
- [Vanilla JS](https://surveyjs.io/survey-creator/examples/manage-toolbox-subitems/vanillajs.md)
