Skip to main content
Version: latest
Works everywhere

RichText works in both server and client environments. Always use the standard import (e.g. @prokodo/ui/rich-text) — the library detects the runtime automatically.

RichText

RichText renders sanitised HTML or Portable Text / structured content from a CMS. Applies prokodo typography styles to all child elements (<h2><h6>, <p>, <a>, <ul>, <ol>, <blockquote>).

Live demo →

Overview

import { RichText } from "@prokodo/ui/rich-text"
;<RichText html={article.content} />

Import

import { RichText } from "@prokodo/ui/rich-text"

CSS:

import "@prokodo/ui/rich-text.css"

Props

PropTypeDefaultRequiredDescription
childrenReactNodeRich text content (React nodes).
animatedbooleanfalseEnable entrance animation.
animationPropsAnimatedPropsEntrance animation config.
colorVariantsAccent color for links and headings.
schemabooleanfalseEmit JSON-LD schema markup.
itemPropstringSchema.org itemprop attribute.
linkComponentComponentTypeCustom link component for internal links.
linkPolicystringPolicy applied to link rendering.
overrideParagraphbooleanfalseReplace <p> elements with custom rendering.
classNamestringCSS class on root element.

See src/components/rich-text/RichText.model.ts for the full RichTextProps type.


Design Tokens

RichText does not define component-specific CSS custom properties. Override appearance by customising the following global design-system tokens on :root or a scoped ancestor:

TokenDescription
--pk-color-brandLink color and ordered list marker fill
--pk-color-mutedParagraph and code text color
--pk-color-fgList item text color
--pk-color-borderCode block and blockquote border color
--pk-color-surface-raisedCode block and blockquote background
--pk-space-lgBlockquote horizontal padding
--pk-space-smList icon right margin
--pk-space-xsList item bottom gap
--pk-radius-smCode block corner radius
--pk-radius-mdInline image corner radius
--pk-palette-whiteOrdered list marker text color

AIC Note

Use the standard import path in application code:

import { RichText } from "@prokodo/ui/rich-text"

No separate /client or /lazy import selection is required in consumer code.

AIC components also support a priority flag for critical above-the-fold elements. This is most visible on Image (native preloading via <link rel="preload"> for above-the-fold content).


WCAG 2.2 Status

CriterionNameStatusNote
1.3.1Info and Relationships (A)✅ FulfilledSemantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA.
1.3.2Meaningful Sequence (A)🔍 Manual reviewContent reading order in the DOM must match the intended visual presentation order.
1.4.3Contrast (Minimum) (AA)🔍 Manual reviewText must have a contrast ratio of at least 4.5:1 (3:1 for large text). Verify against the final product theme.
2.4.6Headings and Labels (AA)🔍 Manual reviewHeadings and labels must describe the topic or purpose of their associated content.
4.1.2Name, Role, Value (A)✅ FulfilledName, role, and state of all interactive UI components must be programmatically determinable via native HTML semantics or ARIA.

Test coverage: 2 jest-axe assertion(s) across 4 test file(s) · 1 ARIA attribute occurrence(s) in source scan. Criteria marked 🔍 require manual verification in the final product integration and theme context.

Storybook

👉 Open RichText in Storybook


Source

src/components/rich-text/RichText.model.ts