Demo

<div class="tpw-widget data-tpw-id="demo">...

Reduced test cases

Stress-Testing the Widget

Features

  • POSH (Plain Old Semantic HTML)

    The Widget relies on Plain Old Semantic HTML (no jump-links needed!).
    Progressive Enhancement FTW (For The Win)!

  • Accessible

    First class support for screen-reader users!
    ARIA controls the rendering of their non-visual experience.

  • Markup Agnostic

    Authors can use any heading they want to structure their content,
    they can even use a Definition List if they wish (dt / dd pairs).

  • Adaptive

    The TabPanel becomes an Accordion if the tabs cannot "fit" horizontally.
    Note that ARIA attributes will change accordingly.

  • Versatile

    Can work as an Accordion out-of-the-box.
    Accordion's icons can either be displayed to the right or left of the text.

  • RTL Friendly

    Tabs flow according to script direction (ltr, rtl).
    Icon's positioning will obey script direction too.

  • State Management

    The widget handles state persistence.
    Reloading, saving, or sharing a URL will reflect that state.

  • Keyboard Friendly

    Supports keyboard navigation (see below).
    Users can skip the entire Widget or reach the first tab/header.

Assuming the focus is on the Widget

Browser Support

This library relies on ResizeObserver but we have a polyfill for browsers that don't support it—as the table below shows.

Browser Support
Sans PolyfillWith Polyfill
WinOSXAndroidiOSWinOSXAndroidiOS
Chrome6464858631316847
Edge80808080
Firefox6969794242657.2
Internet Explorerx10
Opera52521717
Safarix13.113.16.26.27
Samsung9.24.5
UC Browserx12.110.4
Yandexxx14.1214.12

Notes:

  • The polyfill works in Safari 5.1, but in that browser the resizing of the widget is only triggered via window.resize.
  • Accordion icons do not show in IE10. That would require to "dumb down" the styling, going with encodedURI instead of "plain" SVG.

Le Code

Try it on CodePen First!

There is no wrapper requirement. Anything may go in between your headings. The script wraps that content inside <div>s that become the "panels".

Install

FAQ

Tab through to leave this widget
or
follow this link to go back to the first header

Don't see your question? Ask on GitHub!