Accessibility and performance
The components handle the hard parts of keyboard support, focus and loading. Your content still decides most of how accessible and fast a page is, so each section ends with what is left to you.
Accessibility
Every component has automated axe tests, and the interactive ones follow the W3C ARIA Authoring Practices patterns.
| Component | What is built in |
|---|---|
content-overlay | A modal dialog. Focus moves into it and stays there while it is open, Escape or a click outside closes it, and focus goes back to the button that opened it. |
content-tabs | Arrow keys move between tabs, Home and End jump to the first and last. |
content-accordion | A real button that reports whether its panel is open. |
content-carousel | Labelled previous and next buttons and a pause button. Slides stop when keyboard focus moves into the carousel, and never start on their own for people who prefer reduced motion. |
content-navigation-block | A labelled menu button that reports whether the menu is open, and returns focus to it when the menu closes. |
content-button | Tells screen readers when it opens a dialog or controls another element. |
content-image | Looping videos do not play on their own for people who prefer reduced motion. |
The components render in the light DOM, with no shadow DOM, so headings, links and landmarks are ordinary HTML that assistive technology reads the same way as the rest of your page.
Up to you
- Alt text on every meaningful image, and
alt=""on decorative ones. - Headings in order.
content-linetakes atag, so pick the level that fits the page outline. - Link text that makes sense on its own, or a
link-labeloncontent-buttonwhen it does not. - Enough contrast between your text and the images or colours behind it.
- Captions for videos with speech.
Performance
The initial loader is 1.5 KB gzipped. Each component is tree shaken and lazy loaded so only the components used on the page are loaded.
- HTML first. Native web components means content stays in the page's HTML so it can be server rendered and readable by search engines.
- No layout shift from images or videos.
content-imageuses aspect ratio to prevent Cumulative Layout Shift
<content-overlay id="terms">
<script slot="content" type="text/template">
<p>Only added to the page when the overlay opens.</p>
</script>
</content-overlay>Core Web Vitals
Google's Core Web Vitals measure how a page feels to the people using it, and feed into search ranking. Here is how Content Blocks helps with each.
| Metric | Measures | How Content Blocks helps |
|---|---|---|
| Largest Contentful Paint | How soon the main content appears | Components are optimized to prioritize loading assets as soon as they are visible on the screen. |
| Cumulative Layout Shift | How much the page moves while it loads | content-image defines an aspect ratio so it does not resize as the image or video finishes downloading. |
| Interaction to Next Paint | How quickly the page responds to a tap, click or key press | There is no framework to download or virtual DOM to hydrate and all events are native. |