Readtime
On this page
Overview
Provides an estimated reading time for content. Authors
SHOULD provide a selector or nest inside a container.
Authors MUST use %t in light DOM as a minutes placeholder.
AVOID combining word-count with selector. Renders as
inline text readable by screen readers without additional
ARIA roles. No keyboard interaction is needed as this
element is non-interactive display text.
Edit element properties
article p {
font-size: var(--rh-font-size-body-text-md, 1rem);
line-height: var(--rh-line-height-body-text, 1.5);
margin-block-end: 1rem;
}
import '@rhds/elements/rh-readtime/rh-readtime.js';
<meta itemprop="description" content="Uses a CSS selector to target a content container. The component counts words and images from the target element to compute reading time.">
<rh-readtime images="" selector="#article-content">%t min read</rh-readtime>
<article id="article-content">
<p>
Design systems are a collection of reusable components, guided by clear standards,
that can be assembled together to build any number of applications. They help teams
build better products faster by making design reusable and development more consistent.
A design system is more than a pattern library or a set of guidelines. It is a living,
evolving ecosystem that supports both designers and developers in creating cohesive
user experiences across products and platforms.
</p>
<p>
The Red Hat Design System provides a set of web components built on open web standards.
These components follow Red Hat brand guidelines and are designed to work across any
web framework. They are built with accessibility in mind and support theming through
design tokens. The system includes components for layout, navigation, content display,
forms, and feedback. Each component is documented with usage guidelines, code examples,
and accessibility considerations.
</p>
<p>
Web components offer several advantages over traditional framework-specific components.
They work natively in the browser without requiring a build step or framework dependency.
They encapsulate styles and behavior using the Shadow DOM, preventing conflicts with
the rest of the page. They can be used with any JavaScript framework or with no framework
at all. This makes them ideal for design systems that need to support multiple teams
using different technology stacks.
</p>
<img src="placeholder-600x300.svg" alt="Placeholder image" width="600" height="300">
<p>
Reading time estimation is a useful feature for content-heavy pages. It gives readers
an expectation of how long an article will take to read, helping them decide whether
to read now or save for later. Medium popularized this feature, and it has since become
a common pattern on blogs and documentation sites. The algorithm accounts for both
text content and images, since images require additional time to process and understand.
</p>
</article>
import { Readtime } from "@rhds/elements/react/rh-readtime/rh-readtime.js";
// NOTE: React 19+ does not require these wrapper imports.
// You can use the custom elements directly as-is.
export const Demo = () => (
<meta itemprop="description" content="Uses a CSS selector to target a content container. The component counts words and images from the target element to compute reading time." />
<Readtime images selector="#article-content">%t min read</Readtime>
<article id="article-content">
<p>Design systems are a collection of reusable components, guided by clear standards,
that can be assembled together to build any number of applications. They help teams
build better products faster by making design reusable and development more consistent.
A design system is more than a pattern library or a set of guidelines. It is a living,
evolving ecosystem that supports both designers and developers in creating cohesive
user experiences across products and platforms.</p>
<p>The Red Hat Design System provides a set of web components built on open web standards.
These components follow Red Hat brand guidelines and are designed to work across any
web framework. They are built with accessibility in mind and support theming through
design tokens. The system includes components for layout, navigation, content display,
forms, and feedback. Each component is documented with usage guidelines, code examples,
and accessibility considerations.</p>
<p>Web components offer several advantages over traditional framework-specific components.
They work natively in the browser without requiring a build step or framework dependency.
They encapsulate styles and behavior using the Shadow DOM, preventing conflicts with
the rest of the page. They can be used with any JavaScript framework or with no framework
at all. This makes them ideal for design systems that need to support multiple teams
using different technology stacks.</p>
<img src="placeholder-600x300.svg" alt="Placeholder image" width="600" height="300" />
<p>Reading time estimation is a useful feature for content-heavy pages. It gives readers
an expectation of how long an article will take to read, helping them decide whether
to read now or save for later. Medium popularized this feature, and it has since become
a common pattern on blogs and documentation sites. The algorithm accounts for both
text content and images, since images require additional time to process and understand.</p>
</article>
);
CSS selector targeting the content container to read from.
If omitted and word-count is not set, defaults to parentElement.
Manual word count. When set, the component uses this value directly instead of reading from a container.
Manual image count. Enables image time weighting in either mode. In container mode, overrides the DOM image count.
Opt-in to image weighting in container mode.
When set, counts <img> and non-decorative <svg> elements
from the target container. Not needed when image-count is set.
In property mode without image-count, has no effect.
Status
- Figma library:
-
Ready - RH Elements:
-
Ready - RH Shared Libs:
-
Planned
Overview
Read time displays an estimated reading time for a body of content. It helps readers gauge how long an article or page will take to read, improving content discoverability and time management.
The component supports two modes of operation:
- Container mode: Counts words (and optionally images) from a target DOM
element identified by a CSS
selectoror the parent element. - Property mode: Accepts a
word-countand optionalimage-countdirectly via attributes.
Example
Container mode
<rh-readtime selector="#my-article">%t min read</rh-readtime>
<article id="my-article">
<p>Your article content here...</p>
</article>
Property mode
<rh-readtime word-count="1200" image-count="3">%t min read</rh-readtime>
Status checklist
| Property | Status | Meaning |
|---|---|---|
| Figma library |
|
Component is available in the Figma library |
| RH Elements |
|
Component is available in RH Elements |
| RH Shared Libs |
|
Component will be added to RH Shared Libs |
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.
Other libraries
To learn more about our other libraries, visit the getting started page.