# docx-editor-form-fields

> Word editor loads a form-fields document with fillable form content and spinner loading.

**Framework:** react  **Component:** DocxEditor  **Variant:** form-fields

## 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/react/js/docx-editor-form-fields.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-react-documenteditor @syncfusion/ej2-popups
```

**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-form-fields/DocxEditor.jsx

```jsx
import { useEffect, useRef } from 'react';
import { DocumentEditorContainerComponent, Ribbon, Toolbar } from '@syncfusion/ej2-react-documenteditor';
import { formfields } from '../datasource/docx-editor-data';
import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
import { TitleBar } from '../title-bar';
import '../default.component.css';

DocumentEditorContainerComponent.Inject(Toolbar, Ribbon);

const FormFields = () => {
    useEffect(() => {
        rendereComplete();
    }, [])
    const hostUrl = "https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/";
    let container = useRef(null);
    let titleBar;
    let settings = { showRuler: true };
    const onLoadDefault = () => {
        if (!container.current) return;
        container.current.documentEditor.open(JSON.stringify(formfields));
        container.current.documentEditor.documentName = "Form Fields";
        titleBar.updateDocumentTitle();
        container.current.documentChange = () => {
            if (!container.current) return;
            titleBar.updateDocumentTitle();
            container.current.documentEditor.focusIn();
        };
    };
    const rendereComplete = () => {
        if (!container.current) return;
        container.current.documentEditor.pageOutline = "#E0E0E0";
        container.current.documentEditor.acceptTab = true;
        container.current.documentEditor.resize();
        const titleBarElement = document.getElementById("documenteditor_titlebar");
        if (titleBarElement) {
            titleBar = new TitleBar(
                titleBarElement,
                container.current.documentEditor,
                true
            );
        }
        onLoadDefault();
        titleBar.showButtons(false);
    };

    const fileMenuItemClick = (args) => {
        if (!container.current) return;
        if (args.item.id) {
            let value = args.item.id;
            let sampleName = container.current.documentEditor.documentName === '' ? 'sample' : container.current.documentEditor.documentName;
            switch (value) {
                case 'docx':
                    container.current.documentEditor.save(sampleName, 'Docx');
                    break;
                case 'sfdt':
                    container.current.documentEditor.save(sampleName, 'Sfdt');
                    break;
                case 'text':
                    container.current.documentEditor.save(sampleName, 'Txt');
                    break;
                case 'dotx':
                    container.current.documentEditor.save(sampleName, 'Dotx');
                    break;
                case 'pdf':
                    formatSaveLocal('Pdf');
                    break;
                case 'html':
                    formatSaveLocal('Html');
                    break;
                case 'odt':
                    formatSaveLocal('Odt');
                    break;
                case 'md':
                    formatSaveLocal('Md');
                    break;
                case 'rtf':
                    formatSaveLocal('Rtf');
                    break;
                case 'wordml':
                    formatSaveLocal('Xml');
                    break;
            }
        }
    }

    const formatSaveLocal = (type) => {
        if (!container.current) return;
        createSpinner({
            target: document.getElementById('container')
        });
        showSpinner(document.getElementById('container'));
        let format = type;
        let url = container.current.documentEditor.serviceUrl + 'Export';
        let http = new XMLHttpRequest();
        http.open('POST', url);
        http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
        http.responseType = 'blob';

        let sfdt = {
            Content: container.current.documentEditor.serialize(),
            Filename: container.current.documentEditor.documentName,
            Format: '.' + format,
        };

        http.onload = () => {
            if (http.status === 200) {
                if (!container.current) return;
                let responseData = http.response;
                let blobUrl = URL.createObjectURL(responseData);
                let downloadLink = document.createElement('a');
                downloadLink.href = blobUrl;
                downloadLink.download = container.current.documentEditor.documentName + '.' + format.toLowerCase();
                document.body.appendChild(downloadLink);
                hideSpinner(document.getElementById('container'));
                downloadLink.click();
                document.body.removeChild(downloadLink);
                URL.revokeObjectURL(blobUrl);
            } else {
                console.error('Request failed with status:', http.status);
                hideSpinner(document.getElementById('container'));
            }
        };

        http.send(JSON.stringify(sfdt));
    }
    return (
        <div className="control-pane">
            <div className="control-section">
                <div id="documenteditor_titlebar" className="e-de-ctn-title"></div>
                <div id="documenteditor_container_body" style={{ "display": "block", "height": "calc(100vh - 230px)" }}>
                    <DocumentEditorContainerComponent
                        id="container"
                        ref={container}
                        style={{ display: "block" }}
                        height={"100%"}
                        toolbarMode={"Ribbon"}
                        serviceUrl={hostUrl}
                        enableToolbar={true}
                        showPropertiesPane={false}
                        locale="en-US"
                        documentEditorSettings={settings}
                        fileMenuItems={['New', 'Open', {
                            text: 'Export',
                            id: 'custom_item',
                            iconCss: 'e-icons e-export',
                            items: [
                                { id: 'sfdt', text: 'Syncfusion Document Text (*.sfdt)' },
                                { id: 'docx', text: 'Word Document (*.docx)' },
                                { id: 'dotx', text: 'Word Template (*.dotx)' },
                                { id: 'text', text: 'Plain Text (*.txt)' },
                                { id: 'pdf', text: 'PDF (*.pdf)' },
                                { id: 'html', text: 'HyperText Markup Language (*.html)' },
                                { id: 'rtf', text: 'Rich Text Format (*.rtf)' },
                                { id: 'md', text: 'Markdown (*.md)' },
                                { id: 'odt', text: 'OpenDocument Text (*.odt)' },
                                { id: 'wordml', text: 'Word XML Document (*.xml)' }
                            ]
                        }, 'Print']}
                        fileMenuItemClick={fileMenuItemClick}
                    />
                </div>
            </div>
        </div>
    );
}
export default FormFields;

```
