Tabs
Related panels on one page, one shown at a time.
Example
Name, region and default language for the workspace.
Invite people and change their roles.
Billing is managed by your organization.
Two-factor authentication and session length.
<div class="full"> <focsd-tabs label="Workspace settings"> <focsd-tab>General</focsd-tab> <focsd-tab>Members</focsd-tab> <focsd-tab disabled>Billing</focsd-tab> <focsd-tab>Security</focsd-tab> <focsd-tab-panel ><p>Name, region and default language for the workspace.</p></focsd-tab-panel > <focsd-tab-panel><p>Invite people and change their roles.</p></focsd-tab-panel> <focsd-tab-panel><p>Billing is managed by your organization.</p></focsd-tab-panel> <focsd-tab-panel ><p>Two-factor authentication and session length.</p></focsd-tab-panel > </focsd-tabs></div>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-tabs.js';</script>
<focsd-tabs label="Workspace settings">…</focsd-tabs>import { Tabs } from '@focsd-dev/react';
export function Example() { return <Tabs onChange={(e) => console.log(e.target)} label="Workspace settings">…</Tabs>;}<script setup>import '@focsd-dev/components/focsd-tabs.js';</script>
<template> <focsd-tabs @change="onChange" label="Workspace settings">…</focsd-tabs></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-tabs.js';
// template<focsd-tabs (change)="onChange($event)" label="Workspace settings">…</focsd-tabs><script> import '@focsd-dev/components/focsd-tabs.js';</script>
<focsd-tabs onchange={(e) => console.log(e.target)} label="Workspace settings">…</focsd-tabs>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
selected | selected | number | 0 |
label | label | string | — |
Events
| Event | Description |
|---|---|
change | Fired when the user commits a change to the value or state. |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
tab | The focsd-tab elements (assigned to this slot automatically). |
CSS parts
Style the inside of the component with ::part(), for example focsd-tabs::part(panels).
| Part | Description |
|---|---|
panels | The panels element. |
tablist | The tablist element. |
Accessibility
- APG tabs with automatic activation:
role="tablist",tabandtabpanel, witharia-selected,aria-controlsandaria-labelledbyset on the hosts. - One tab stop for the tab list; disabled tabs are skipped; arrows are mirrored in right-to-left pages.
Keyboard
| Key | Action |
|---|---|
| Arrow Left / Right | Previous / next tab (selects it) |
| Home / End | First / last tab |
| Tab | Move into the active panel |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.