RichText
Organism component for displaying rich text content with optional title. Renders CMS RichText component content.
Props
The component accepts all fields from the RichText type directly:
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
title | string | No | - | Rich text section title |
title_tag | "h1" | "h2" | "h3" | "h4" | "p" | No | "h2" | HTML tag for title |
title_variant | TypographyVariant | No | - | Typography variant for title styling |
fancy_background | boolean | No | - | Adds gradient background with rounded corners (curated-product-card-gradient) |
copy | JSONRTE | No | - | Rich text content (JSON RTE format) |
$ | CSLPFieldMapping | No | - | CSLP mapping for editable fields |
noPadding | boolean | No | false | Removes section padding (used when nested in TwoColumn) |
Usage
import { RichText } from '@/components/organisms/RichText';
<RichText
title="Section Title"
title_tag="h2"
title_variant="cs-h2"
copy={richTextContent}
$={cslpMapping}
/>Features
- Title support: Optional title with configurable HTML tag and typography variant
- Rich text rendering: Uses
RichTextRendereratom for JSON RTE content - Typography variants: Supports all Title component variants via
title_variant - CSLP support: Supports Contentstack Live Preview for all fields
- Prose styling: Rich text content uses
proseclass for typography - Fancy background: Optional gradient background with
curated-product-card-gradientstyling - No padding: Supports
noPaddingfor nested use inside TwoColumn
Title Variants
The title_variant prop accepts any value from the Title component's TypographyVariant type:
"cs-h1-display","h1-standard","h1-compact","h1-display-compact""cs-h1-header","cs-h1-3xl""cs-h2","cs-h3","cs-h4","cs-h5","cs-h6""hero-text","section-heading"
Component Structure
<section className={`${noPadding ? "" : "section"} ${fancy_background ? "curated-product-card-gradient p-6 rounded-lg" : ""}`}>
{title && (
<Title
text={title}
as={title_tag || 'h2'}
variant={title_variant || undefined}
$={$?.title}
classes="mb-4"
/>
)}
{copy && (
<div className="prose" {...getCSLPAttributes($?.copy)}>
<RichTextRenderer json={copy} />
</div>
)}
</section>Notes
- Returns
nullif bothtitleandcopyare missing - Title is optional - component can render with just rich text content
- Uses
proseclass for rich text content styling - Integrated into ComponentsRenderer system (available as
rich_textcomponent)