Accessibility · Component reference
Typography studio
Independent control over text size, type, spacing, alignment and line length.
Try the live exampleResearch and our take
Our recorded research compared reader preferences and accessibility tools across several projects. For this component, these observations informed Starlit’s approach:
- Fluid UI Options: Separate adjusters for type, contrast, spacing, links, inputs and table of contents. Our decision: Build small independent panels backed by a shared preference controller.
Starlit wrote the shared controller, scoped content adapters and component modules presented here. The referenced widgets are research sources, not browser dependencies. The component also draws on interface work in EvansWiki and PayCal.
Design reasoning
Reading comfort involves spacing and measure as well as larger letters.
- Start with the person’s task and the barrier they may encounter.
- Use beside substantial prose. Wrap authored reading text in data-a11y-prose and allow containers to grow with it.
- Keep the ordinary content and action usable before adding enhancement.
- Increase every spacing control, use the largest text size, then inspect labels, paragraphs and long links at 320 CSS pixels.
Usage pattern
Use beside substantial prose. Wrap authored reading text in data-a11y-prose and allow containers to grow with it.
Impact and tradeoffs
Greater spacing may improve tracking but makes a page longer. A fixed height can turn a helpful preference into clipped content.
Accessibility solutions
Keep text real, support enlargement, preserve start alignment for writing direction, and avoid spacing overrides on icons or decorative lettering.
Build accessible source content first. Personal preferences supplement semantic HTML, useful names, keyboard access and visible focus.
HTML
A concrete usage example. Host these assets on your own origin if you adapt the pattern. Read the source and credits before reuse.
<link rel="stylesheet" href="/open-ui/accessibility/shared/content.css">
<script type="module"
src="/open-ui/accessibility/components/typography-panel/index.js"></script>
<article id="reading" data-sdou-a11y-content data-default-theme="dark">
<div data-sdou-a11y-prose>
<h2 id="begin">Begin with a clear purpose</h2>
<p>Readable text and useful controls belong together.</p>
<h2 id="details">Consider the details</h2>
<p>The page should remain usable before any enhancement loads.</p>
</div>
</article>
<sdou-typography-panel target="#reading"
storage-key="example.typography-panel.v1"></sdou-typography-panel>CSS
This is the component stylesheet used inside its Shadow DOM. The shared ui.css supplies its base controls and content.css adapts the reading region. An empty component stylesheet deliberately inherits the shared UI.
/* Typography studio. Component specific layout, shared controls live in shared/ui.css. */
JavaScript
This is the actual component module used by the live example. Imports, the base class and shared preferences are dependencies. Keep the component folder and shared folder in their relative positions.
import { A11yComponent, typography, preview } from "../../shared/base.js?v=sdou20261029";
class TypographyPanel extends A11yComponent {
static styles = new URL("./component.css?v=sdou20261029", import.meta.url).href;
render() {
this.mount(
"Make the words comfortable.",
"Choose the size, spacing and type that work for you. The preview changes as you adjust.",
typography() + preview,
);
}
}
customElements.define("sdou-typography-panel", TypographyPanel);
PHP integration
In your own application, PHP can render this HTML on the server. Here, the example is escaped text only. The library has no PHP runner or execution endpoint. The browser owns the interaction.
<?php
// Server render trusted structure and escape authored text.
// PHP does not implement or save these browser preferences.
declare(strict_types=1);
$title = 'A readable article';
$paragraph = 'Your authored content goes here.';
$e = static fn (string $value): string =>
htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
?>
<link rel="stylesheet" href="/open-ui/accessibility/shared/content.css">
<script type="module"
src="/open-ui/accessibility/components/typography-panel/index.js"></script>
<article id="reading" data-sdou-a11y-content data-default-theme="dark">
<div data-sdou-a11y-prose>
<h2 id="begin"><?= $e($title) ?></h2>
<p><?= $e($paragraph) ?></p>
</div>
</article>
<sdou-typography-panel target="#reading"
storage-key="example.typography-panel.v1"></sdou-typography-panel>
API and dependencies
- Element
sdou-typography-panel- target
- A selector for the content region. Use a unique ID. Components sharing a target share its controller.
- storage-key
- A stable key for this project. Use the same key for controls targeting the same region. Preferences stay in browser storage when available.
- Content
data-sdou-a11y-contentmarks the target;data-sdou-a11y-proseidentifies reading copy. Usedata-default-theme="dark"for a dark initial and reset preference.- Event
sdou:a11y-changeis dispatched on the target withpreferences,paletteandreducedMotionin its detail.- Dependencies
- Modern JavaScript modules, custom elements, Shadow DOM and native form controls. Dialog, speech, clipboard and fullscreen support depend on the feature and browser.
Read shared/base.js · Read the preference controller · Read the content adapter · Read the shared control styles
Testing and limitations
Increase every spacing control, use the largest text size, then inspect labels, paragraphs and long links at 320 CSS pixels.
The original library validation records automated rule checks, 320px reflow, enlarged text, text spacing, state persistence and relevant functional checks. Unresolved automated Shadow DOM reference checks are recorded separately from browser dialog checks. These historical results are not a new audit of every integration.
Production review still needs assistive technology, touch, zoom, custom styles and representative content. See our testing scope and known gaps. Report a barrier to Starlit.