Customization

Document styles

Apply DOCX paragraph styles from your template with the packaged style picker or your own React and Vue picker.

Paragraph styles come from the loaded DOCX template. Use Toolbar.StylePicker or the useParagraphStyle() hook to apply them.

Apply a document style

Mount this picker inside DocxEditor.Root. It applies the option's styleId, not its display name.

import { useParagraphStyle } from '@docx-editor.dev/react';

export function ContractStylePicker() {
  const { value, options, isEnabled, setValue } = useParagraphStyle();
  return (
    <select
      aria-label="Paragraph style"
      disabled={!isEnabled}
      value={value ?? ''}
      onChange={(event) => setValue(event.currentTarget.value)}
    >
      <option value="" disabled>
        Mixed or default
      </option>
      {options.map((option) => (
        <option key={option.styleId} value={option.styleId}>
          {option.name}
        </option>
      ))}
    </select>
  );
}

To use the packaged picker, render <DocxEditor.Toolbar.StylePicker />. Its Trigger, Content, and Item parts support a custom arrangement.

Configure picker options

useParagraphStyle() memberUse
valueCurrent styleId. null can mean a mixed selection.
optionsParagraph styles from the document, standard styles first.
isEnabledWhether the selection accepts a style change.
setValue(styleId)Applies a style.
Option fieldUse
styleIdStable identifier to apply.
nameDisplay label.
previewfontFamily, fontSizePt, bold, italic, and color.

Prepare the template

  • Give each style a stable styleId and a readable name.
  • Use w:basedOn to inherit a shared design.
  • Define tables, lists, sections, headers, and theme fonts in the template.

For template preparation, see Custom styles and branding.

Limits

  • The built-in picker does not filter by w:qFormat, w:hidden, or w:semiHidden. Filter options in a custom picker.
  • Do not show a null value as a selected style.
  • Direct formatting can override a style's properties. Clear Formatting removes it where the engine allows.
  • Existing tables keep their style references and w:tblLook. New tables use explicit borders and do not inherit the default table style.
  • Interface CSS does not change saved document styles or supply font metrics. Load font bytes through Fonts.
  • For rendering support, see DOCX feature support.

See also