Skip to content
Norn
Menu

norn-rich-text

Prose styles for long-form content: headings, paragraphs, lists, quotes, tables, rules, and inline code, all at one line height. A heading that links to itself is a norn-heading-anchor, which styles its own # and takes the same space above as a plain heading. Wrap the content in it: <norn-rich-text><template webc:nokeep @html="content"></template></norn-rich-text>. Rules in tables and dividers and the quote bar take --norn-ui-border-color, and inline code --norn-surface-code.

<norn-rich-text> a container, from @allons-y/webc-patterns

Examples

Color scheme
Width

Open on its own

Source
<norn-rich-text>
	<p>A paragraph with <code>inline code</code> and a <a href="https://example.com/">link</a>.</p>
	<h2>A second-level heading</h2>
	<ul>
		<li>A list item</li>
		<li>Run the build once before changing any file, so the output folder exists and the cache is warm</li>
	</ul>
	<ol>
		<li>First</li>
		<li>Second</li>
	</ol>
	<h3>A third-level heading</h3>
	<blockquote>Simple things should be simple, and complex things should be possible.</blockquote>
	<table>
		<thead><tr><th>Option</th><th>Default</th></tr></thead>
		<tbody>
			<tr><td><code>exclude</code></td><td><code>[]</code></td></tr>
			<tr><td><code>prefix</code></td><td><code>"/"</code></td></tr>
		</tbody>
	</table>
	<hr />
	<p>After the rule.</p>
</norn-rich-text>
Color scheme
Width

Open on its own

Source
<norn-rich-text>
	<norn-heading-anchor @slug="first">A linked second-level heading</norn-heading-anchor>
	<p>A short line of body text.</p>
	<norn-heading-anchor @slug="second" :@level="3">A linked third-level heading</norn-heading-anchor>
	<p>A short line of body text.</p>
</norn-rich-text>
Color scheme
Width

Open on its own

Source
<norn-rich-text>
	<picture>
		<source media="(min-width: 600px)" srcset="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='200'%3E%3Crect width='1200' height='200' fill='%23888'/%3E%3C/svg%3E" />
		<img alt="A wide gray bar" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='200'%3E%3Crect width='1200' height='200' fill='%23888'/%3E%3C/svg%3E" />
	</picture>
</norn-rich-text>
Color scheme
Width

Open on its own

Source
<norn-rich-text>
	<blockquote>Simple things should be simple, and complex things should be possible.</blockquote>
	<blockquote>
		<p>The power of the Web is in its universality.</p>
		<cite>Tim Berners-Lee</cite>
	</blockquote>
	<figure>
		<blockquote><p>Any sufficiently advanced technology is indistinguishable from magic.</p></blockquote>
		<figcaption>Arthur C. Clarke, <cite>Profiles of the Future</cite></figcaption>
	</figure>
</norn-rich-text>
Color scheme
Width

Open on its own

Source
<div style="display: grid; gap: 1.5rem">
	<div style="display: grid; gap: 0.5rem">
		<p><code>measure = text</code></p>
		<div>
			<norn-rich-text @measure="text"></norn-rich-text>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>measure = none</code></p>
		<div>
			<norn-rich-text @measure="none"></norn-rich-text>
		</div>
	</div>
</div>

Props

Write them with the @ prefix, and :@ for an expression.

NameTypeDescription
@measure string Line length: text, --norn-text-measure, or none, the full width, as in a page whose prose holds to the measure child by child. Falls back to text.

Slots

NameDescription
default The prose, as rendered HTML.

Tokens

The global tokens from tokens.json the component reads. Set one in a project's tokens.css to change it everywhere.

Type a value to try it in every example above. Reset puts the default back.

Token Type Default Override
--norn-ui-accentThe brand color, shared by every component. <color> #2346d4
--norn-ui-border-colorHairline color. <color> light-dark(#d3d8e2, #2d323e)
--norn-ui-radius-sCorner radius of a part inside a component, and of inline code. A component's own radius is ui.border.radius. <length> 4px
--norn-surface-codeCode surface. <color> light-dark(hsl(40, 14%, 94%), #2c313b)
--norn-text-mutedSecondary text color. <color> light-dark(#4b5160, #a4abba)
--norn-text-measureLine length for prose. <length> 40em
--norn-font-headingHeading face. Follows the body face until the project sets one. <font-family> var(--norn-font-body, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif)
--norn-font-monoCode face. <font-family> ui-monospace, SFMono-Regular, Menlo, Consolas, monospace
--norn-font-size-sSmall text: captions, code, navigation, and notes. <length> 0.875rem
--norn-font-size-mBody text. <length> 1rem
--norn-font-size-lLede, card title, and third-level heading. <length> 1.25rem
--norn-font-size-xlSecond-level heading. Larger titles use a clamp. <length> 1.5rem
--norn-space-xsExtra small spacing step. <length> 0.5rem
--norn-space-sSmall spacing step. <length> 0.75rem
--norn-space-mMedium spacing step. <length> 1.25rem