# Declarative Approach

## Content

<span id="68025142-f322-47cd-9079-42508793765a" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="68025142-f322-47cd-9079-42508793765a" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">The declarative approach defines the ToolStrip layout directly in Razor markup. Use this method when the structure of the toolbar is known beforehand and when explicitly placing each tool (buttons, toggles, separators, dropdowns) in a fixed order is necessary. This approach offers full control over the visual layout and simplifies manual design.</span>
![](https://cdn.mescius.io/document-site-files/images/f5b600ba-f1a7-4f89-a20c-aa6c0c35880d/Declarative.5b2f12.png?width=600)

### **Create ToolStrip in Razor Markup**

1. <span id="74e0145c-14eb-46cb-acf9-bcc4b5ed74f9" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="74e0145c-14eb-46cb-acf9-bcc4b5ed74f9" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Add the </span>**<span id="74e0145c-14eb-46cb-acf9-bcc4b5ed74f9" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="74e0145c-14eb-46cb-acf9-bcc4b5ed74f9" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">ToolStrip</span>**<span id="74e0145c-14eb-46cb-acf9-bcc4b5ed74f9" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="74e0145c-14eb-46cb-acf9-bcc4b5ed74f9" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation"> component:</span>

```auto
<C1ToolStrip>
</C1ToolStrip>
```

<span id="a53ba0a4-bd79-40b3-b65f-f9134a44064b" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="a53ba0a4-bd79-40b3-b65f-f9134a44064b" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">2\. Add a </span>**<span id="a53ba0a4-bd79-40b3-b65f-f9134a44064b" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="a53ba0a4-bd79-40b3-b65f-f9134a44064b" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Dropdown</span>** <span id="a53ba0a4-bd79-40b3-b65f-f9134a44064b" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="a53ba0a4-bd79-40b3-b65f-f9134a44064b" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">tool:</span>

```auto
<C1DropDownTool Label="Options" IconTemplate="C1IconTemplate.ThreeDotsHorizontal">
    <ContentTemplate>
        <!-- custom dropdown content -->
    </ContentTemplate>
</C1DropDownTool>
```

<span id="77cf4f1f-6beb-4f0a-b73e-78fb12e8b4dc" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="77cf4f1f-6beb-4f0a-b73e-78fb12e8b4dc" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">3\. Insert a </span>**<span id="77cf4f1f-6beb-4f0a-b73e-78fb12e8b4dc" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="77cf4f1f-6beb-4f0a-b73e-78fb12e8b4dc" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Separator</span>**<span id="77cf4f1f-6beb-4f0a-b73e-78fb12e8b4dc" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="77cf4f1f-6beb-4f0a-b73e-78fb12e8b4dc" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">:</span>

```auto
<C1ToolSeparator />
```

<span id="c21d1568-7cd5-4c58-9f0c-6b09717c5f3d" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="c21d1568-7cd5-4c58-9f0c-6b09717c5f3d" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">4\. Add a </span>**<span id="c21d1568-7cd5-4c58-9f0c-6b09717c5f3d" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="c21d1568-7cd5-4c58-9f0c-6b09717c5f3d" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Button</span>** <span id="c21d1568-7cd5-4c58-9f0c-6b09717c5f3d" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="c21d1568-7cd5-4c58-9f0c-6b09717c5f3d" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">tool:</span>

```auto
<C1ButtonTool Label="Select All" IconTemplate="C1IconTemplate.SelectAll" />
```

<span id="0c29bbb5-edf2-4623-b9cd-cc665fe1e4d3" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="0c29bbb5-edf2-4623-b9cd-cc665fe1e4d3" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">5\. Add a </span>**<span id="0c29bbb5-edf2-4623-b9cd-cc665fe1e4d3" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="0c29bbb5-edf2-4623-b9cd-cc665fe1e4d3" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Toggle</span>**<span id="0c29bbb5-edf2-4623-b9cd-cc665fe1e4d3" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="0c29bbb5-edf2-4623-b9cd-cc665fe1e4d3" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation"> tool:</span>

```auto
<C1ToggleButtonTool Label="Filter" IconTemplate="C1IconTemplate.Funnel" />
```

<span id="70df54c8-5fc2-496e-b075-897de10d9218" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="70df54c8-5fc2-496e-b075-897de10d9218" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">6\. Add </span>**<span id="70df54c8-5fc2-496e-b075-897de10d9218" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="70df54c8-5fc2-496e-b075-897de10d9218" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Menu</span>**<span id="70df54c8-5fc2-496e-b075-897de10d9218" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="70df54c8-5fc2-496e-b075-897de10d9218" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation"> tool:</span>

```auto
<C1MenuTool Label="edit" Description="(C1MenuTool)" IconTemplate="C1IconTemplate.Edit">
    <C1MenuTool Label="misc" IconTemplate="C1IconTemplate.ThreeDotsHorizontal">
        <C1ButtonTool Label="paste" Padding="5" IconTemplate="C1IconTemplate.MinusSquare" />
        <C1SelectTool Label="items count" Description="(C1SelectTool)"
                      IconTemplate="C1IconTemplate.Copy"
                      ItemsSource="selectToolItems"/>
    </C1MenuTool>
</C1MenuTool>
```

<span id="b60f2cf0-6af8-480f-a3de-3f5cf0d77aa2" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="b60f2cf0-6af8-480f-a3de-3f5cf0d77aa2" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">7\. Add </span>**<span id="b60f2cf0-6af8-480f-a3de-3f5cf0d77aa2" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="b60f2cf0-6af8-480f-a3de-3f5cf0d77aa2" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">Select</span>** <span id="b60f2cf0-6af8-480f-a3de-3f5cf0d77aa2" annotationtype="inlineComment" data-mark-type="annotation" data-mark-annotation-type="inlineComment" data-id="b60f2cf0-6af8-480f-a3de-3f5cf0d77aa2" data-prosemirror-content-type="mark" data-prosemirror-mark-name="annotation">tool:</span>

```auto
<C1SelectTool Label="items count" Description="(C1SelectTool)"
    IconTemplate="C1IconTemplate.Copy"
    ItemsSource="selectToolItems"
    Style="selectToolStyle" />
```

### **Declarative Approach Sample**

```auto
 <C1ToolStrip @ref="toolStrip" GroupCornerRadius="16"
                 Style="@($"background: linear-gradient(90deg, #f5f7fa 0%, #c3cfe2 100%); border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); padding: 12px; border: 1px solid #e0e0e0;")"
                 OverflowDropDownStyle="@("background: green !important; padding: 12px !important; border: 3px solid red !important;")"
                 ToolStyle="@("border: thin solid; margin: 3px;")">

        <C1DropDownTool Label="options" Description="(C1DropDownTool)">
            <ContentTemplate>
                <div style="display: grid; grid-template-columns: max-content max-content; gap: 8px; padding: 4px 12px 12px 8px;">
                    Orientation
                    <C1ComboBox T="Orientation"/>
                    Tool orientation
                    <C1ComboBox T="Orientation"/>
                    Overflow
                    <C1ComboBox T="ToolStripOverflow"/>
                    isLabelVisible
                    <C1CheckBox/>
                </div>
            </ContentTemplate>
        </C1DropDownTool>

        <C1ToolSeparator Foreground="@("#888")" />

        <C1ButtonTool Label="select all" Description="(C1ButtonTool)" />

        <C1ToggleButtonTool Label="filter" Description="(C1ToggleButtonTool)" IconTemplate="C1IconTemplate.Funnel" />

        <C1SelectTool Label="items count" Description="(C1SelectTool)"
                      IconTemplate="C1IconTemplate.Copy"
                      ItemsSource="selectToolItems"
                      Style="selectToolStyle" />

        <C1MenuTool Label="edit" Description="(C1MenuTool)" IconTemplate="C1IconTemplate.Edit">
            <C1ButtonTool Label="add" IconTemplate="C1IconTemplate.PlusSquare"/>
            <C1ButtonTool Label="remove" Padding="5" IconTemplate="C1IconTemplate.MinusSquare" />
            <C1MenuTool Label="misc" IconTemplate="C1IconTemplate.ThreeDotsHorizontal">
                <C1ButtonTool Label="paste" Padding="5" IconTemplate="C1IconTemplate.MinusSquare" />
                <C1SelectTool Label="items count" Description="(C1SelectTool)"
                              IconTemplate="C1IconTemplate.Copy"
                              ItemsSource="selectToolItems"/>
            </C1MenuTool>
        </C1MenuTool>
    </C1ToolStrip>
```