OverviewDocsPreviewsBuilder

Content Viewer

Render the rich content safely in read-only mode with identical styles.

To display the content created in your Tiptide editors elsewhere in your application, you should use the <Viewer /> component.

Relying on standard dangerouslySetInnerHTML without Tiptide's predefined styles will result in unstyled headings, lists, blockquotes, and tables. The <Viewer /> component automatically bundles Tiptide's custom styling engine and renders content safely and accurately.

Features

  • Universal Parser: Accepts either an HTML string or a parsed Tiptap JSON content object.
  • Exact Style Matching: Uses the identical Tailwind CSS classes (tiptide-preview and prose typography extensions) that the interactive editor uses.
  • Highly Responsive: Out-of-the-box support for responsive container scrolling, wide code-blocks, and scaled images.

Example

tsx
import { Viewer, type TiptideJSONContentType } from 'tiptide';

// Let's assume we fetch JSON or HTML content from a database
interface PostProps {
  title: string;
  content: string | TiptideJSONContentType;
}

export function Post({ title, content }: PostProps) {
  return (
    <article className="max-w-2xl mx-auto py-8">
      <h1 className="text-3xl font-bold mb-6">{title}</h1>
      
      {/* Renders content beautifully with identical typography */}
      <Viewer 
        content={content} 
        className="text-neutral-800 leading-relaxed dark:text-neutral-200"
        containerClassName="border border-neutral-100 rounded-lg p-6 bg-white dark:bg-neutral-950 dark:border-neutral-800"
      />
    </article>
  );
}