This independent HTML document reads the shared preference before
its content paints. There is no app router or React runtime on this
page.
01 / Initialization
Independent documents can agree
Use the same origin, storage key, stable profile IDs and styles in
your application and documentation. Load the browser bundle,
optional preset bundle and configuration synchronously in the
head.
The Vision profile uses the text-spacing override values from WCAG
1.4.12. Your CSS consumes the line height, paragraph, letter and
word spacing tokens. These values are an override recipe, not a
required default design.
Compose the optional presets into a profile’s
tokens.
Use the custom properties in headings, body text, navigation and
controls.
Check the real page at 320 CSS pixels, with enlarged text and
your users’ settings.
Vision + High Contrast also uses paired palette tokens whose solid
text pairs exceed 7:1. Other colors, imagery and component states
still need their own checks.
03 / WHATWG HTML integration
Keep the native behavior.
The widget uses a real label, select and options. The
native-controls recipe uses platform color tokens; it cannot
create semantics. Use labeled inputs, real links and buttons in
the surrounding page as well.
A token preset does not establish accessibility conformance. See
the
standards and token preset guide
for the distinction and sources.
Source code
These are the files behind this example. The tabs support arrow keys, Home and End.
docs.html
<!doctype html><htmllang="en"><head><metacharset="UTF-8" /><metaname="viewport"content="width=device-width,initial-scale=1" /><title>Static documentation — Open Regard Display</title><!-- Self-host synchronous scripts so the saved profile applies before paint. --><scriptsrc="../dist/display.browser.js"></script><scriptsrc="../dist/presets.browser.js"></script><scriptsrc="./config.js"></script><linkrel="stylesheet"href="../dist/style.css" /><linkrel="stylesheet"href="./demo.css" /><linkrel="icon"href="./mark.svg"type="image/svg+xml" /></head><body><aclass="skip"href="#main">Skip to content</a><headerclass="masthead shell"><aclass="brand"href="https://openregard.org/"
><imgsrc="./mark.svg"alt="" />open regard.</a
>
<spanclass="meta">Module 01 / Display / Runnable examples</span></header><navclass="example-nav shell"aria-label="Example navigation"><ahref="./">Vanilla HTML</a
><ahref="./docs.html"aria-current="page">Static docs</a
><ahref="./react.html">React</a
><ahref="https://openregard.org/docs/">Library documentation ↗</a></nav><mainid="main"class="shell"><sectionclass="hero"><div><pclass="eyebrow">02 / Static HTML</p><h1>A separate page.<br /><em>The same settings.</em></h1><pclass="intro">
This independent HTML document reads the shared preference before
its content paints. There is no app router or React runtime on this
page.
</p></div><asideclass="control-card"aria-label="Display settings"><pclass="eyebrow">Try a display profile</p><divid="controls"></div></aside></section><divclass="doc-layout"><navclass="doc-index"aria-label="Example document sections"><ahref="#initialize">01 / Initialize</a
><ahref="#tokens">02 / Apply tokens</a
><ahref="#html">03 / Use native HTML</a></nav><articleclass="doc-article"><sectionid="initialize"><pclass="eyebrow">01 / Initialization</p><h2>Independent documents can agree</h2><p>
Use the same origin, storage key, stable profile IDs and styles in
your application and documentation. Load the browser bundle,
optional preset bundle and configuration synchronously in the
head.
</p><preclass="code-note"
><code><script src="/assets/openregard.js"></script><script src="/assets/presets.js"></script><script src="/assets/display-config.js"></script></code></pre></section><sectionid="tokens"><pclass="eyebrow">02 / WCAG-informed presentation</p><h2>Connect tokens to your CSS.</h2><p>
The Vision profile uses the text-spacing override values from WCAG
1.4.12. Your CSS consumes the line height, paragraph, letter and
word spacing tokens. These values are an override recipe, not a
required default design.
</p><olclass="steps"><li>
Compose the optional presets into a profile’s
<code>tokens</code>.
</li><li>
Use the custom properties in headings, body text, navigation and
controls.
</li><li>
Check the real page at 320 CSS pixels, with enlarged text and
your users’ settings.
</li></ol><p>
Vision + High Contrast also uses paired palette tokens whose solid
text pairs exceed 7:1. Other colors, imagery and component states
still need their own checks.
</p></section><sectionid="html"><pclass="eyebrow">03 / WHATWG HTML integration</p><h2>Keep the native behavior.</h2><p>
The widget uses a real label, select and options. The
native-controls recipe uses platform color tokens; it cannot
create semantics. Use labeled inputs, real links and buttons in
the surrounding page as well.
</p><pclass="recipe-note">
A token preset does not establish accessibility conformance. See
the
<ahref="https://openregard.org/docs/#standards-and-token-presets"
>standards and token preset guide</a
>
for the distinction and sources.
</p></section></article></div></main><footerclass="shell"><p>
Open Regard / Display. Profiles and page styles are configured by the
site. Test your integration with your content and users.
</p><ahref="https://github.com/inferal-oss/openregard">View the project ↗</a></footer><script>OpenRegardDisplay.mountDisplayWidget(
document.getElementById("controls"),
regard,
{
className: "demo-widget",
},
);
</script></body></html>
config.js
// Optional token recipes. Profile names, composition and site styling are yours.const { wcagPresets, htmlPresets } = OpenRegardPresets;
window.regardConfig = {
version: 1,
defaultProfile: "standard",
storageKey: "openregard-example",
controlLabel: "Reading and display preferences",
profiles: [
{
id: "standard",
label: "Standard",
description: "The original site presentation.",
},
{
id: "roomy",
label: "Vision",
description: "Larger text with the WCAG text-spacing override values.",
tokens: {
...wcagPresets.textSpacing,
...htmlPresets.nativeControls,
"--regard-font-size": "125%",
},
},
{
id: "vision-contrast",
label: "Vision + High Contrast",
description:
"Larger, spaced text with a restrained palette and stronger borders.",
tokens: {
...wcagPresets.textSpacing,
...wcagPresets.contrastLight,
...htmlPresets.nativeControls,
"--regard-font-size": "125%",
},
},
{
id: "strong",
label: "Max Contrast",
description:
"Larger text, generous spacing and black-and-white surfaces.",
tokens: {
...wcagPresets.textSpacing,
...htmlPresets.nativeControls,
"--regard-font-size": "150%",
"--regard-page-ink": "#000",
"--regard-page-paper": "#fff",
"--regard-panel-ink": "#fff",
"--regard-panel-paper": "#000",
"--regard-border-color": "#000",
},
},
],
};
window.regard = OpenRegardDisplay.createDisplay(window.regardConfig);
window.stopRegard = window.regard.start();