Skip to content

Divider ​

Insert a horizontal rule between sections or visually separate content blocks.

Import ​

ts
import { dividerPlugin, type DividerOptions } from 'docx-kit'

Options ​

OptionTypeDefaultDescription
style'solid' | 'dashed' | 'dotted' | 'double''solid'Border style for the separator
colorstring'D9D9D9'Divider color in hex
spacingBeforenumber200Paragraph spacing before the rule
spacingAfternumber200Paragraph spacing after the rule

Example ​

ts
import { createDocx, dividerPlugin } from 'docx-kit'

const doc = createDocx()
  .use(dividerPlugin())
  .h1('Quarterly Review')
  .plugin('divider', { style: 'double', color: '4472C4' })
  .p('Executive summary starts here.')

Style customization ​

Pass { styles } to the factory for instance defaults, and options.styles for invocation overrides. The package and docx-kit entry points export DividerConfig and DividerStyles. Priority: built-in/theme defaults → initialization styles → common node style → invocation part styles. Nested fields merge; arrays replace; undefined retains defaults; 0 and false apply. Units and theme tokens such as $colors.primary are supported.

PartsStyle typeScope
paragraphParagraphStyleRuleBackground, borders, alignment, spacing and flow
ts
dividerPlugin({
  styles: { paragraph: { borderBottom: { color: '#2563EB', width: 2 }, marginTop: 0 } },
})

Use the same part names in options.styles for a single call. JSON DSL, AI tool schemas and MCP validation share these contracts; unknown parts and misplaced properties are rejected.

Released under the MIT License.