Skip to content
Content Blocks docsv0.8.0Website

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.

ComponentWhat is built in
content-overlayA 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-tabsArrow keys move between tabs, Home and End jump to the first and last.
content-accordionA real button that reports whether its panel is open.
content-carouselLabelled 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-blockA labelled menu button that reports whether the menu is open, and returns focus to it when the menu closes.
content-buttonTells screen readers when it opens a dialog or controls another element.
content-imageLooping 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-line takes a tag, so pick the level that fits the page outline.
  • Link text that makes sense on its own, or a link-label on content-button when 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-image uses 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.

MetricMeasuresHow Content Blocks helps
Largest Contentful PaintHow soon the main content appearsComponents are optimized to prioritize loading assets as soon as they are visible on the screen.
Cumulative Layout ShiftHow much the page moves while it loadscontent-image defines an aspect ratio so it does not resize as the image or video finishes downloading.
Interaction to Next PaintHow quickly the page responds to a tap, click or key pressThere is no framework to download or virtual DOM to hydrate and all events are native.