Skip to content
Brok UI

Loading…

No results

Document Editors

Pro

Pro editing surfaces for documents; spreadsheet editing is excel-viewer's `editable` mode.

Version
v1.2.1
Stability
experimental
License
Commercial license
Related
Button
Spinner

DOCX Editor — An experimental token-styled .docx editor that converts Word documents with mammoth.js, sanitizes the resulting HTML, and provides an editable surface with formatting and loading/error states.

Warning

Experimental API — it can change before stabilization. Do not use it in a core pattern until it reaches stable.

Send experiment feedback

Preview

Loading document…
previews.components.docx-editor.default.blade.php Blade
<div class="mx-auto h-[36rem] w-full max-w-3xl">
    <x-ui.experimental.docx-editor src="/samples/sample.docx" />
</div>

Installation

terminal
php artisan ui:add pro/docx-editor --accept-unstable

Note

This component ships an Alpine behavior module at resources/js/ui/docx-editor.js. Import it once from your bundle so it registers on alpine:init:

resources/js/ui/index.js JS
import './docx-editor.js';

Use with AI

A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.

docx-editor.md
# Brok UI: DOCX Editor (`docx-editor`)

An experimental token-styled .docx editor that converts Word documents with mammoth.js, sanitizes the resulting HTML, and provides an editable surface with formatting and loading/error states.

Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.

## Install

```bash
php artisan ui:add pro/docx-editor --accept-unstable
```

## Usage

```blade
<div class="mx-auto h-[36rem] w-full max-w-3xl">
    <x-ui.experimental.docx-editor src="/samples/sample.docx" />
</div>
```

## Use when

- Use when users need to upload, inspect, edit, annotate, or sign real documents as part of the workflow.
- Applying lightweight browser-side edits to the HTML rendered from a .docx file.

## Avoid when

- Do not use a heavy document interface when the same task can be completed more simply in structured product UI.
- Edits must be written back to a .docx file or preserve Word layout exactly. Use docx-viewer for read-only rendering, or a server-side Word conversion pipeline, instead.

## Anti-patterns

- Heavy document UI when structured fields are simpler

## Rules

- Use the `<brok:docx-editor>` tag (or `<x-ui.docx-editor>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.

## Links

- Docs: https://brokui.dev/docs/components/docx-editor

Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.

Examples

long-content.blade.php Blade
<div class="mx-auto h-[36rem] w-full max-w-xs">
    <x-ui.experimental.docx-editor src="/samples/sample.docx" />
</div>

API

manifest knowledge + registry-derived coverage

Props

No documented props. Pass normal Blade attributes through the component root.

Slots

Default Blade slot only.

Data slots

Stable hooks for CSS overrides and browser tests.

No data-slot selectors found in the registry source.

Behavior

  • Converts with mammoth.js, then sanitizes the generated HTML through a strict DOMPurify allow-list before placing it in the contenteditable x-html surface.
  • Exposes edited HTML only; it does not write changes back to the source .docx file.
  • Installs a JavaScript behavior module when the registry item includes resources/js/ui files.

Guidance

Document workflow

Upload, inspect, edit, annotate, or sign a real document.

Use when

  • Use when users need to upload, inspect, edit, annotate, or sign real documents as part of the workflow.
  • Applying lightweight browser-side edits to the HTML rendered from a .docx file.

Avoid when

  • Do not use a heavy document interface when the same task can be completed more simply in structured product UI.
  • Edits must be written back to a .docx file or preserve Word layout exactly. Use docx-viewer for read-only rendering, or a server-side Word conversion pipeline, instead.

Use instead

  • Structured product form
  • Direct data entry

Anti-patterns

  • Heavy document UI when structured fields are simpler
Anatomy
editor formatting toolbar document surface loading state error state
Theming hooks
Toolbar, document, borders, and focus indicators use semantic design tokens.

Accessibility

WCAG 2.2 AA Keyboard focus-visible RTL-ready Localized labels Dark mode
Keyboard
No component-owned keyboard interaction; native element behavior applies.
Focus
none
  • Formatting buttons expose pressed state and the editable document is a labelled multiline textbox.
  • Semantic HTML and a stable data-slot attribute for styling and scripting hooks.
  • Focus-visible rings use the ring token, so keyboard focus is always visible.
  • Disabled and invalid states are conveyed to assistive tech, not by color alone.
  • Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
  • Labels go through __() and layout uses logical properties (ms-*, text-start), so it mirrors under dir="rtl" — flip the preview to RTL to confirm.
  • Dark mode uses the same semantic tokens under the dark class; high contrast follows forced-color system tokens.

Livewire

Safe

Livewire can update this component through forwarded wire:* attributes.

Source

Source available with Pro

This preview shows the real Pro component, while its installable source is delivered only through the authenticated registry. Activate a license, then use the installation command above.

Open the authenticated source endpoint

Ownership & lifecycle

Owner, release state, review evidence and adoption for this item.
Owner
Platform UI (@JoshJML)
Current version
1.2.1
Status
Experimental
License
pro
Accessibility reviewed
No review date recorded
Last breaking change
No date recorded
Deprecation
Not deprecated

Adoption evidence

Projects
0
References
0
Survey responses
0
Recommendation
Not assessed

Entered 2026-06-13. Evidence assessed not yet.