domestic-ui GitHub

Tabs

Sections of content shown one at a time, chosen from a list of tabs.

Where tabs are used Tabs are a row of labels under a heading in the content area, with the panel of the selected tab right below them.

Live example

Automatic activation

<dui-tabs>
  <nav aria-label="Account settings">
    <ul>
      <li><a href="#tab-profile">Profile</a></li>
      <li><a href="#tab-security">Security</a></li>
      <li><a href="#tab-notifications">Notifications</a></li>
    </ul>
  </nav>
  <section id="tab-profile">
    <h3>Profile</h3>
    <p>Your name and photo appear on comments and shared projects.</p>
  </section>
  <section id="tab-security">
    <h3>Security</h3>
    <div data-field>
      <label for="tab-security-code">Recovery code</label>
      <input id="tab-security-code" name="recovery" type="text" autocomplete="off">
    </div>
  </section>
  <section id="tab-notifications">
    <h3>Notifications</h3>
    <p>Email alerts are on. You get a weekly digest on Mondays.</p>
  </section>
</dui-tabs>

Manual activation

<dui-tabs activation="manual">
  <nav aria-label="Report period">
    <ul>
      <li><a href="#tab-week">Week</a></li>
      <li><a href="#tab-month" aria-current="true">Month</a></li>
      <li><a href="#tab-year">Year</a></li>
    </ul>
  </nav>
  <section id="tab-week">
    <h3>Week</h3>
    <p>42 orders this week.</p>
  </section>
  <section id="tab-month">
    <h3>Month</h3>
    <p>180 orders this month.</p>
  </section>
  <section id="tab-year">
    <h3>Year</h3>
    <p>2,140 orders this year.</p>
  </section>
</dui-tabs>

Right to left

<div dir="rtl" lang="ar">
  <dui-tabs>
    <nav aria-label="الإعدادات">
      <ul>
        <li><a href="#tab-rtl-general">عام</a></li>
        <li><a href="#tab-rtl-privacy">الخصوصية</a></li>
        <li><a href="#tab-rtl-help">مساعدة</a></li>
      </ul>
    </nav>
    <section id="tab-rtl-general">
      <h3>عام</h3>
      <p>الإعدادات العامة للحساب.</p>
    </section>
    <section id="tab-rtl-privacy">
      <h3>الخصوصية</h3>
      <p>من يمكنه رؤية ملفك الشخصي.</p>
    </section>
    <section id="tab-rtl-help">
      <h3>مساعدة</h3>
      <p>الأسئلة الشائعة والدعم.</p>
    </section>
  </dui-tabs>
</div>

Attributes

Attribute or valueWhereEffect
<dui-tabs>wraps a <nav aria-label> with a list of <a href="#panel-id"> links, then the panels
activation="manual"<dui-tabs>arrows move focus, Enter or Space selects (default: automatic)
aria-current="true"a linkthe tab selected on load (else the tab named in the URL fragment, else the first)
role="tablist" | "tab" | "tabpanel"added by the component; styled here

Keyboard

KeyAction
Tabmoves into the tab list (to the selected tab), then to the panel
Right Arrow / Left Arrownext or previous tab, wrapping (swapped in right-to-left)
Home / Endfirst or last tab
Enter / Spaceselects the focused tab (manual activation)

Accessibility

  • The selected tab has a bar and full-strength text, not color alone (WCAG 1.4.11).
  • Without JavaScript, every section shows and the links work as a table of contents.
  • Our choice: automatic activation, as the APG recommends for fast panels. activation="manual" otherwise.

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

Search