# docx-editor-default

> Document editor with toolbar and ribbon modes for Word editing, with essential document controls.

**Framework:** blazor  **Component:** DocxEditor  **Variant:** default

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/blazor/docx-editor-default.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.Blazor.WordProcessor
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/docx-editor-default/DocxEditor.razor

```razor
@page "/document-editor/default-functionalities"
@namespace blazor.Components.Pages.Default.Default
@using System.Text.Json
@using Syncfusion.Blazor.Buttons;
@using Syncfusion.Blazor.DocumentEditor;

<div class="control-section">
    <div>
        <div id='documenteditor_titlebar' class="e-de-ctn-title">
            <div class="single-line" id="documenteditor_title_contentEditor" style="border: 1px solid transparent;" title="Document Name." contenteditable="false">
                <label id="documenteditor_title_name" class="doc-edit-title"> @DocumentName</label>
            </div>
            <div style="float: right">
                <SfButton IconCss="e-de-icon-Print" CssClass="title-bar-btn" @onclick="Print">Print</SfButton>
            </div>
            <div style="float: right">
                <SfButton IconCss="e-de-icon-Download" CssClass="title-bar-btn" @onclick="OnExport">Download</SfButton>
            </div>
        </div>
        <div>
            <SfDocumentEditorContainer @ref="_containerRef" Height="590px" RestrictEditing="@ReadOnly" ShowPropertiesPane="@ShowProperties" DocumentEditorSettings="_settings">
                <DocumentEditorContainerEvents Created="OnCreated" DocumentChanged="OnDocumentChange" ></DocumentEditorContainerEvents>
            </SfDocumentEditorContainer>
        </div>
    </div>
</div>
@code {
    internal string? DocumentName { get; set; }
    internal bool ReadOnly { get; set;  }
    internal bool ShowProperties { get; set; } = true;
    private SfDocumentEditorContainer? _containerRef;
    private DocumentEditorSettingsModel _settings = new DocumentEditorSettingsModel() { ShowRuler = true};
    public void OnExport(object args)
    {
        if (_containerRef != null)
        {
            SfDocumentEditor documentEditor = _containerRef.DocumentEditor;
            documentEditor.SaveAsync(DocumentName, FormatType.Docx);
        }
    }
    public void Print(object args)
    {
        if (_containerRef != null)
        {
            SfDocumentEditor documentEditor = _containerRef.DocumentEditor;
            documentEditor.PrintAsync();
        }
    }
    public async Task OnCreated(object args)
    {
        if (_containerRef != null)
        {
            SfDocumentEditor documentEditor = _containerRef.DocumentEditor;
            if (documentEditor != null)
            {
                string text = "Pick a field on the left to insert a merge field at the cursor position.";

                var sfdt = new
                {
                    sections = new[]
                    {
                    new
                    {
                        blocks = new[]
                        {
                            new
                            {
                                inlines = new[]
                                {
                                    new { text }
                                }
                            }
                        },
                        headerFooter = new { },
                        sectionFormat = new
                        {
                            pageWidth = 612,
                            pageHeight = 792,
                            leftMargin = 72,
                            rightMargin = 72,
                            topMargin = 72,
                            bottomMargin = 72
                        }
                    }
                }
                };

                string json = JsonSerializer.Serialize(sfdt);
                await documentEditor.OpenAsync(json);
                DocumentName = "Getting Started";
                await InvokeAsync(StateHasChanged);
            }
        }
    }
    public void OnDocumentChange()
    {
        if (_containerRef != null)
        {
            string name = _containerRef.DocumentEditor.DocumentName;
            if (name != "")
            {
                DocumentName = name;
            }
        }
    }
}
<style>
    .title-bar-btn, .title-bar-btn:hover, .title-bar-btn:focus {
        background: transparent;
        box-shadow: none;
        font-family: inherit;
        border-color: transparent;
        border-radius: 2px;
        color: inherit;
        font-size: 12px;
        text-transform: capitalize;
        height: 28px;
        font-weight: 400;
        margin-top: 2px;
    }
    #documenteditor_titlebar {
        border-bottom: 1px solid #3f51b5;
        height: 36px;
        line-height: 26px;
        width: 100%;
        font-size: 12px;
        padding-left: 15px;
        padding-right: 10px;
        font-family: inherit;
    }
    #documenteditor_title_contentEditor {
        height: 26px;
        max-width: 85%;
        width: auto;
        overflow: hidden;
        display: inline-block;
        padding-left: 4px;
        padding-right: 4px;
        margin: 5px;
    }
    .doc-edit-title {
        text-transform: capitalize;
        font-weight: 400;
        font-family: inherit;
        text-overflow: ellipsis;
        outline: none;
        white-space: pre;
        overflow: hidden;
        user-select: none;
        cursor: text
    }
    .single-line {
        cursor: text !important;
        outline: none;
    }
    [contenteditable="true"].single-line {
        white-space: nowrap;
        border-color: #e4e4e4 !important;
    }
    /** Document editor sample level font icons*/
    @@font-face {
        font-family: 'Sample brower icons';
        font-weight: normal;
        font-style: normal;
    }
    [class^="e-de-icon-"],
    [class*=" e-de-icon-"] {
        font-family: 'Sample brower icons' !important;
    }
    .e-de-icon-Print:before {
        content: "\e723";
        font-family: 'Sample brower icons' !important;
    }
    .e-de-icon-Download:before {
        content: "\e728";
        font-family: 'Sample brower icons' !important;
    }
</style>
```
