# Name Box

## Content

<span lang="EN-US" style="font-size:12.0pt;font-family:Montserrat;mso-fareast-font-family:
Montserrat;mso-bidi-font-family:Montserrat;color:#3A4652">SpreadJS provides an Excel-like name box component to display selected ranges, items, and named ranges. This feature helps to add a name box component along with the spread control in your project.</span>
<span lang="EN-US" style="font-size:12.0pt;line-height:107%;font-family:Montserrat;
mso-fareast-font-family:Montserrat;mso-bidi-font-family:Montserrat;color:#3A4652;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA">The NameBox generally displays the address of the selected cell. The NameBox consists of a selector and a dropdown.</span>
![namebox-container.png](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/namebox-container.f8028b.png)
You can display selection in the NameBox selector as shown below:

* Display changing selection when the selection is changing.
    ![select-a-range.png](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/select-a-range.9597ff.png)
* Display the active cell when the selection is set down.
    ![namebox-gif.gif](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/namebox-gif.427d32.gif)
* Display the drawing name when the drawing is selected.
    ![selection-drawing.png](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/selection-drawing.147c9f.png)
* Display the name when the selection is equal to the named range or table name.
    ![select-table.png](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/select-table.addd81.png)

<span lang="EN-US" style="font-size:12.0pt;font-family:Montserrat;mso-fareast-font-family:
Montserrat;mso-bidi-font-family:Montserrat;color:#3A4652">The dropdown of NameBox displays the following custom name list:</span>

* <span lang="EN-US" style="font-size:12.0pt;
    font-family:Montserrat;mso-fareast-font-family:Montserrat;mso-bidi-font-family:
    Montserrat;color:#3A4652">Workbook custom names and its expression type which is equal to GC.Spread.CalcEngine.ExpressionType.reference.</span>
* <span lang="EN-US" style="font-size:12.0pt;
    font-family:Montserrat;mso-fareast-font-family:Montserrat;mso-bidi-font-family:
    Montserrat;color:#3A4652">Active worksheet custom names and its expression type which is equal to GC.Spread.CalcEngine.ExpressionType.reference.</span>
* <span lang="EN-US" style="font-size:12.0pt;
    font-family:Montserrat;mso-fareast-font-family:Montserrat;mso-bidi-font-family:
    Montserrat;color:#3A4652">All table names of all worksheets.</span>

## Configure NameBox

To create a name box component, follow these steps:

1. Add the `gc.spread.sheets.all.x.x.x.min.js` reference in the HTML.

    ```JavaScript
    <script type="text/javascript" src="scripts/modules/gc.spread.sheets.all.x.x.x.min.js"></script>
    ```
2. <span lang="EN-US" style="font-size:10.5pt;line-height:
    107%;font-family:Montserrat;mso-fareast-font-family:Calibri;mso-fareast-theme-font:
    minor-latin;mso-bidi-font-family:Times New Roman;mso-bidi-theme-font:minor-bidi;
    color:black;background:white;mso-ansi-language:EN-US;mso-fareast-language:EN-US;
    mso-bidi-language:AR-SA">Add a host DIV element.</span>

    ```JavaScript
    <div id="NameBox" style="width:100px"></div>
    ```
3. Bind the [NameBox](https://grapecity-document-site.azurewebsites.net/spreadjs/api/classes/GC.Spread.Sheets.NameBox.NameBox) element to the Spread instance.

    ```JavaScript
    var sheet = spread.getActiveSheet();
    var nameBox = new GC.Spread.Sheets.NameBox.NameBox(document.getElementById('NameBox'), spread);
    ```
4. You can further add NameBox options, see the following **Set NameBox Options** section.

## Set NameBox Options

You can add various options to control the behavior of the NameBox such as setting drop-down list height, adding custom names, navigating to ranges, and showing custom names using the **[INameBoxOptions](https://grapecity-document-site.azurewebsites.net/spreadjs/api/interfaces/GC.Spread.Sheets.NameBox.INameBoxOptions)** interface.

| Option Name | Value | Description |
| ----------- | ----- | ----------- |
| dropDownMaxHeight | Number | Indicates the maximum height of the drop-down list. The default value is 500px. |
| enableAddCustomName | Boolean | Indicates whether to add a custom name when inputting a name, which does not exist in the selector. The default value is true. |
| enableNavigateToRange | Boolean | Indicates whether to navigate to the named range or drawing item when inputting its name or clicking a custom list item. The default value is true. |
| showCustomNameList | Boolean | Indicates whether to show the custom name list dropdown indicator. |

The following code shows how to set the NameBox options:

```JavaScript
 var nameBox = new GC.Spread.Sheets.NameBox.NameBox(document.getElementById('NameBox'), spread, {
                showCustomNameList: false,
                dropDownMaxHeight: 200,
                enableAddCustomName: false,
                enableNavigateToRange: false
 });
```

> **Note**: You can apply different Excel themes to NameBox. For more information on applying themes to SpreadJS components, see [Themes](/spreadjs/docs/v16/features/styletheme).