Skip to main content
Programmatic API for customizing how Tailwind classes map to DOCX properties. Use this when a tailwind.config file isn’t enough — custom handlers, brand colors at runtime, or replacing built-in behavior.

createTailwindParser

Factory function that returns a TailwindParser instance:
You can also use the class directly:

Options


Custom colors

Then use in your document:
Color values are hex strings without the # prefix.

Custom fonts


Custom handlers

A ClassHandler is a function that processes a Tailwind class and writes the result:
Return true if the class was handled, false to pass it to the next handler.

Adding extra handlers

Extra handlers run before the built-in pipeline:

Replacing built-in handlers

Override a specific handler by name. You can delegate to the original via defaultHandlerMap:

Handler names

All built-in handlers that can be replaced:

TailwindParseResult

The result object that handlers write to:
Each field maps to a group of DOCX properties. Handlers set individual properties on these objects.

Passing to render

Pass your parser to render or renderToBuffer:
When no parser is provided, a default instance is used that loads from your tailwind.config file automatically.