Skip to main content
htmlSnippet() parses small HTML fragments into Satori-compatible React nodes. It works around Satori’s inline layout limitation by splitting text into per-word flex items with flex-wrap and gap.
Trusted input only. htmlSnippet is designed for HTML authored by template developers — not arbitrary end-user content. Disallowed tags and attributes are stripped with a plain-text fallback.

Import

Function Signature

Parameters

value
string
required
HTML fragment or plain text. When no HTML tags are detected, the string is returned unchanged (plain mode).
options
HtmlSnippetOptions
Layout options for the word container in HTML mode.

Returns

result
ReactNode
  • Plain mode — returns the original string.
  • HTML mode — returns a flex container with per-word <span> children, preserving inline styles from allowed tags.

Allowed Tags

Only these inline tags are permitted: Tags like div, p, a, img, script, and event handlers (onclick, etc.) are rejected. Invalid fragments fall back to plain text with a development warning.

Examples

Migration from objectToStyle

objectToStyle has been removed from @ogify/core. Use htmlSnippet for inline styled text, or write inline style attributes / clsx for layout:
The basic template uses htmlSnippet for both title and subtitle, enabling rich inline styling with Tailwind-like classes on <span> elements.