Skip to content

Tabs that turn into an accordion

Accessible tabs on large screens that turn into an accordion on phones, with the right ARIA roles in each mode.

  • Tailwind
  • React
  • CSS
  • WordPress
Open in a new tab

Description

Tabs are perfect on desktop but quickly overflow on phones, where an accordion reads naturally. This component presents the same content both ways and switches with the available width (40 rem), live when the screen rotates or the window is resized. In tabs mode: role="tablist", aria-selected, roving focus, left and right arrows, Home and End, role="tabpanel" panels reachable with the keyboard. In accordion mode: buttons inside level 3 headings with aria-expanded, role="region" panels named by their button, several sections open at once. The choice carries over between modes: the selected tab stays open in the accordion. Without JavaScript all sections show one under another with their heading. 44 px targets, AA contrast in light and dark mode, an accordion arrow animated only without prefers-reduced-motion. Example: the classes of a cooking school.

Code

Loading the code…

The code of this component in

Archive contents

onglets-accordeon-adaptatif-html-tailwind.zip3 files · 5 Ko

  • index.html12 Ko
  • README.md4 Ko
  • LICENSE.md1 Ko

Tags

Updated on December 2, 2026.

Reviews

No reviews yet.

In the same spirit

  • Indicative prices sorted by trade in tabs, with the unit of each service, a VAT-inclusive / excl. switch and a free-quote notice.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Vertical tabs

    Coming soon

    A column of tabs on the left and content on the right, for settings and customer area pages.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Understated tabs with an underlined active tab, to organize the information on a product page.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Pill tabs

    Coming soon

    A pill selector in a rounded track, to compare plans or variants.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component