# Tabs

Tabs for switching between content panels, with WAI-ARIA keyboard navigation.

- Category: Navigation
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/tabs.json
- CLI: `npx markasui@latest add tabs`

## When to use

Grouping peer content on one page, for example account, profile, and security settings.

- Tab keys or values use only lowercase letters, digits, and underscores because they become ids and slot names
- Do not use Tabs to navigate between pages, use regular links

## Code

### Blade

Save at `resources/views/components/markas/tabs.blade.php`. Dependencies: alpinejs.

```blade
@props([
    'items' => [],
    'defaultValue' => null,
])

@php
    $root = 'w-full';
    $list = 'inline-flex items-center gap-1 rounded-lg bg-subtle p-1';
    $tab = 'inline-flex h-8 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap text-muted transition-colors duration-150 ease-out hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=active]:bg-surface data-[state=active]:text-ink motion-reduce:transition-none';
    $panel = 'mt-4 rounded-md text-sm text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary';

    $keys = array_map('strval', array_keys($items));
    $active = $defaultValue ?? ($keys[0] ?? null);
    // Same id on every render, so Livewire's morph (which matches elements by id) keeps the element. Pass `id` to set it.
    $idKey = 'markas-tabs|'.(isset($this) && $this instanceof \Livewire\Component ? $this->getId() : '').'|'.($attributes->get('wire:key') ?? $attributes->whereStartsWith('wire:model')->first() ?? $attributes->get('name')).'|';
    for ($idIndex = 0; $__env->hasRenderedOnce($idKey.$idIndex); $idIndex++);
    $__env->markAsRenderedOnce($idKey.$idIndex);
    $id = $attributes->get('id') ?? 'markas-tabs-'.hash('xxh32', $idKey.$idIndex);
@endphp

<div
    x-data="{
        active: @js($active),
        keys: @js($keys),
        focusTab(key) {
            this.active = key;
            this.$nextTick(() => document.getElementById(@js($id) + '-tab-' + key).focus());
        },
        move(step) {
            const index = this.keys.indexOf(this.active);
            this.focusTab(this.keys[(index + step + this.keys.length) % this.keys.length]);
        },
    }"
    {{ $attributes->merge(['id' => $id])->class([$root]) }}
>
    <div
        role="tablist"
        aria-orientation="horizontal"
        class="{{ $list }}"
        @keydown.right.prevent="move(1)"
        @keydown.left.prevent="move(-1)"
        @keydown.home.prevent="focusTab(keys[0])"
        @keydown.end.prevent="focusTab(keys[keys.length - 1])"
    >
        @foreach ($items as $key => $label)
            @php $selected = (string) $key === $active; @endphp
            <button
                type="button"
                role="tab"
                id="{{ $id }}-tab-{{ $key }}"
                aria-controls="{{ $id }}-panel-{{ $key }}"
                aria-selected="{{ $selected ? 'true' : 'false' }}"
                tabindex="{{ $selected ? '0' : '-1' }}"
                data-state="{{ $selected ? 'active' : 'inactive' }}"
                :aria-selected="active === @js((string) $key) ? 'true' : 'false'"
                :tabindex="active === @js((string) $key) ? 0 : -1"
                :data-state="active === @js((string) $key) ? 'active' : 'inactive'"
                @click="active = @js((string) $key)"
                class="{{ $tab }}"
            >{{ $label }}</button>
        @endforeach
    </div>
    @foreach ($items as $key => $label)
        @php $selected = (string) $key === $active; @endphp
        <div
            role="tabpanel"
            id="{{ $id }}-panel-{{ $key }}"
            aria-labelledby="{{ $id }}-tab-{{ $key }}"
            tabindex="0"
            data-state="{{ $selected ? 'active' : 'inactive' }}"
            @unless ($selected) hidden @endunless
            :hidden="active !== @js((string) $key)"
            :data-state="active === @js((string) $key) ? 'active' : 'inactive'"
            class="{{ $panel }}"
        >{{ $__laravel_slots[(string) $key] ?? '' }}</div>
    @endforeach
</div>
```

```blade
<x-markas.tabs :items="['account' => 'Account', 'password' => 'Password']" default-value="account">
    <x-slot:account>Change your account name and email.</x-slot:account>
    <x-slot:password>Change your password regularly.</x-slot:password>
</x-markas.tabs>
```

Needs Alpine.js.

### React

Save at `src/components/markas/Tabs.tsx`. No extra dependencies.

```tsx
"use client";

import {
  useId,
  useRef,
  useState,
  type ComponentProps,
  type KeyboardEvent,
  type ReactNode,
} from "react";

const root = "w-full";
const list = "inline-flex items-center gap-1 rounded-lg bg-subtle p-1";
const tab =
  "inline-flex h-8 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap text-muted transition-colors duration-150 ease-out hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=active]:bg-surface data-[state=active]:text-ink motion-reduce:transition-none";
const panel =
  "mt-4 rounded-md text-sm text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary";
const cx = (...c: (string | false | null | undefined)[]) =>
  c.filter(Boolean).join(" ");

export type TabItem = {
  value: string;
  label: ReactNode;
  content: ReactNode;
};

export type TabsProps = Omit<ComponentProps<"div">, "defaultValue"> & {
  items: TabItem[];
  defaultValue?: string;
  onValueChange?: (value: string) => void;
};

export function Tabs({
  items,
  defaultValue,
  onValueChange,
  id,
  className,
  ...props
}: TabsProps) {
  const generatedId = useId();
  const tabsId = id ?? generatedId;
  const [active, setActive] = useState(defaultValue ?? items[0]?.value);
  const tabRefs = useRef<Record<string, HTMLButtonElement | null>>({});

  const select = (value: string) => {
    setActive(value);
    onValueChange?.(value);
  };
  const focusTab = (value: string) => {
    select(value);
    tabRefs.current[value]?.focus();
  };
  const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
    const keys = items.map((item) => item.value);
    const index = keys.indexOf(active ?? "");
    const targets: Record<string, string | undefined> = {
      ArrowRight: keys[(index + 1) % keys.length],
      ArrowLeft: keys[(index - 1 + keys.length) % keys.length],
      Home: keys[0],
      End: keys[keys.length - 1],
    };
    const target = targets[event.key];
    if (target === undefined) return;
    event.preventDefault();
    focusTab(target);
  };

  return (
    <div id={tabsId} className={cx(root, className)} {...props}>
      <div
        role="tablist"
        aria-orientation="horizontal"
        className={list}
        onKeyDown={handleKeyDown}
      >
        {items.map((item) => {
          const selected = item.value === active;
          return (
            <button
              key={item.value}
              ref={(node) => {
                tabRefs.current[item.value] = node;
              }}
              type="button"
              role="tab"
              id={`${tabsId}-tab-${item.value}`}
              aria-controls={`${tabsId}-panel-${item.value}`}
              aria-selected={selected}
              tabIndex={selected ? 0 : -1}
              data-state={selected ? "active" : "inactive"}
              onClick={() => select(item.value)}
              className={tab}
            >
              {item.label}
            </button>
          );
        })}
      </div>
      {items.map((item) => {
        const selected = item.value === active;
        return (
          <div
            key={item.value}
            role="tabpanel"
            id={`${tabsId}-panel-${item.value}`}
            aria-labelledby={`${tabsId}-tab-${item.value}`}
            tabIndex={0}
            data-state={selected ? "active" : "inactive"}
            hidden={!selected}
            className={panel}
          >
            {item.content}
          </div>
        );
      })}
    </div>
  );
}
```

```tsx
import { Tabs } from "@/components/markas/Tabs";

<Tabs
  defaultValue="account"
  items={[
    {
      value: "account",
      label: "Account",
      content: "Change your account name and email.",
    },
    {
      value: "password",
      label: "Password",
      content: "Change your password regularly.",
    },
  ]}
/>;
```

### Vue

Save at `src/components/markas/Tabs.vue`. No extra dependencies.

```vue
<script setup lang="ts">
import { computed, nextTick, useId } from "vue";

export type TabItem = { value: string; label: string };

const props = defineProps<{
  items: TabItem[];
  defaultValue?: string;
  id?: string;
}>();
const model = defineModel<string>();

const root = "w-full";
const list = "inline-flex items-center gap-1 rounded-lg bg-subtle p-1";
const tab =
  "inline-flex h-8 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap text-muted transition-colors duration-150 ease-out hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=active]:bg-surface data-[state=active]:text-ink motion-reduce:transition-none";
const panel =
  "mt-4 rounded-md text-sm text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary";

const generatedId = useId();
const tabsId = computed(() => props.id ?? generatedId);
const active = computed(
  () => model.value ?? props.defaultValue ?? props.items[0]?.value,
);

async function focusTab(value: string) {
  model.value = value;
  await nextTick();
  document.getElementById(`${tabsId.value}-tab-${value}`)?.focus();
}

function onKeydown(event: KeyboardEvent) {
  const keys = props.items.map((item) => item.value);
  const index = keys.indexOf(active.value ?? "");
  const targets: Record<string, string | undefined> = {
    ArrowRight: keys[(index + 1) % keys.length],
    ArrowLeft: keys[(index - 1 + keys.length) % keys.length],
    Home: keys[0],
    End: keys[keys.length - 1],
  };
  const target = targets[event.key];
  if (target === undefined) return;
  event.preventDefault();
  focusTab(target);
}
</script>

<template>
  <div :id="tabsId" :class="root">
    <div
      role="tablist"
      aria-orientation="horizontal"
      :class="list"
      @keydown="onKeydown"
    >
      <button
        v-for="item in props.items"
        :id="`${tabsId}-tab-${item.value}`"
        :key="item.value"
        type="button"
        role="tab"
        :aria-controls="`${tabsId}-panel-${item.value}`"
        :aria-selected="item.value === active ? 'true' : 'false'"
        :tabindex="item.value === active ? 0 : -1"
        :data-state="item.value === active ? 'active' : 'inactive'"
        :class="tab"
        @click="model = item.value"
      >
        {{ item.label }}
      </button>
    </div>
    <div
      v-for="item in props.items"
      :id="`${tabsId}-panel-${item.value}`"
      :key="item.value"
      role="tabpanel"
      :aria-labelledby="`${tabsId}-tab-${item.value}`"
      tabindex="0"
      :data-state="item.value === active ? 'active' : 'inactive'"
      :hidden="item.value !== active"
      :class="panel"
    >
      <slot :name="item.value" />
    </div>
  </div>
</template>
```

```vue
<template>
  <Tabs
    default-value="account"
    :items="[
      { value: 'account', label: 'Account' },
      { value: 'password', label: 'Password' },
    ]"
  >
    <template #account>Change your account name and email.</template>
    <template #password>Change your password regularly.</template>
  </Tabs>
</template>
```

### Svelte

Save at `src/lib/components/markas/Tabs.svelte`. No extra dependencies.

```svelte
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type TabItem = {
    value: string;
    label: string;
    /** Panel content: plain text or a snippet. */
    content?: string | Snippet;
  };
</script>

<script lang="ts">
  import type { HTMLAttributes } from "svelte/elements";

  const root = "w-full";
  const list = "inline-flex items-center gap-1 rounded-lg bg-subtle p-1";
  const tab =
    "inline-flex h-8 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap text-muted transition-colors duration-150 ease-out hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=active]:bg-surface data-[state=active]:text-ink motion-reduce:transition-none";
  const panel =
    "mt-4 rounded-md text-sm text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary";

  type Props = HTMLAttributes<HTMLDivElement> & {
    items: TabItem[];
    defaultValue?: string;
    /** Active tab, bindable with bind:value. */
    value?: string;
    onValueChange?: (value: string) => void;
  };

  let {
    items,
    defaultValue,
    value = $bindable(),
    onValueChange,
    id,
    class: className,
    ...rest
  }: Props = $props();

  const generatedId = $props.id();
  const tabsId = $derived(id ?? generatedId);
  const active = $derived(value ?? defaultValue ?? items[0]?.value);

  function select(next: string) {
    value = next;
    onValueChange?.(next);
  }

  function handleKeydown(event: KeyboardEvent) {
    const keys = items.map((item) => item.value);
    const index = keys.indexOf(active ?? "");
    const targets: Record<string, string | undefined> = {
      ArrowRight: keys[(index + 1) % keys.length],
      ArrowLeft: keys[(index - 1 + keys.length) % keys.length],
      Home: keys[0],
      End: keys[keys.length - 1],
    };
    const target = targets[event.key];
    if (target === undefined) return;
    event.preventDefault();
    select(target);
    document.getElementById(`${tabsId}-tab-${target}`)?.focus();
  }
</script>

<div id={tabsId} class={[root, className]} {...rest}>
  <!-- svelte-ignore a11y_interactive_supports_focus -->
  <div
    role="tablist"
    aria-orientation="horizontal"
    class={list}
    onkeydown={handleKeydown}
  >
    {#each items as item (item.value)}
      {@const selected = item.value === active}
      <button
        type="button"
        role="tab"
        id={`${tabsId}-tab-${item.value}`}
        aria-controls={`${tabsId}-panel-${item.value}`}
        aria-selected={selected}
        tabindex={selected ? 0 : -1}
        data-state={selected ? "active" : "inactive"}
        onclick={() => select(item.value)}
        class={tab}>{item.label}</button
      >
    {/each}
  </div>
  {#each items as item (item.value)}
    {@const selected = item.value === active}
    <div
      role="tabpanel"
      id={`${tabsId}-panel-${item.value}`}
      aria-labelledby={`${tabsId}-tab-${item.value}`}
      tabindex="0"
      data-state={selected ? "active" : "inactive"}
      hidden={!selected}
      class={panel}
    >
      {#if typeof item.content === "string"}{item.content}{:else}{@render item.content?.()}{/if}
    </div>
  {/each}
</div>
```

```svelte
<script lang="ts">
  import Tabs from "$lib/components/markas/Tabs.svelte";

  let active = $state("account");
  const items = [
    { value: "account", label: "Account", content: account },
    {
      value: "password",
      label: "Password",
      content: "Change your password regularly.",
    },
  ];
</script>

{#snippet account()}
  <p>Change your account name and <strong>email</strong>.</p>
{/snippet}

<Tabs {items} bind:value={active} />
```

`content` is plain text or a snippet declared at the top level of the template.

### Astro

Save at `src/components/markas/Tabs.astro`. No extra dependencies.

```astro
---
import type { HTMLAttributes } from "astro/types";

const root = "w-full";
const list = "inline-flex items-center gap-1 rounded-lg bg-subtle p-1";
const tab =
  "inline-flex h-8 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap text-muted transition-colors duration-150 ease-out hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=active]:bg-surface data-[state=active]:text-ink motion-reduce:transition-none";
const panel =
  "mt-4 rounded-md text-sm text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary";

export type TabItem = { value: string; label: string };

type Props = HTMLAttributes<"div"> & {
  items: TabItem[];
  defaultValue?: string;
};

const { items, defaultValue, id, class: className, ...rest } = Astro.props;
const tabsId = id ?? `markas-tabs-${crypto.randomUUID().slice(0, 8)}`;
const active = defaultValue ?? items[0]?.value;
const panels = await Promise.all(
  items.map((item) => Astro.slots.render(item.value)),
);
---

<div id={tabsId} class:list={[root, className]} {...rest}>
  <div role="tablist" aria-orientation="horizontal" class={list}>
    {
      items.map((item) => {
        const selected = item.value === active;
        return (
          <button
            type="button"
            role="tab"
            id={`${tabsId}-tab-${item.value}`}
            aria-controls={`${tabsId}-panel-${item.value}`}
            aria-selected={selected ? "true" : "false"}
            tabindex={selected ? 0 : -1}
            data-state={selected ? "active" : "inactive"}
            data-markas-tab={item.value}
            class={tab}
          >{item.label}</button>
        );
      })
    }
  </div>
  {
    items.map((item, index) => {
      const selected = item.value === active;
      return (
        <div
          role="tabpanel"
          id={`${tabsId}-panel-${item.value}`}
          aria-labelledby={`${tabsId}-tab-${item.value}`}
          tabindex="0"
          data-state={selected ? "active" : "inactive"}
          hidden={!selected}
          class={panel}
          set:html={panels[index]}
        />
      );
    })
  }
</div>

<script>
  // One listener per page serves every Tabs instance, including markup added later.
  // Selecting a tab dispatches a bubbling "markas-change" event with the value as detail.
  const tabOf = (target: EventTarget | null) =>
    target instanceof Element
      ? target.closest<HTMLButtonElement>("[data-markas-tab]")
      : null;

  function select(next: HTMLButtonElement) {
    for (const item of next.parentElement!.children) {
      const selected = item === next;
      const panel = document.getElementById(
        item.getAttribute("aria-controls") ?? "",
      );
      item.setAttribute("aria-selected", String(selected));
      item.setAttribute("tabindex", selected ? "0" : "-1");
      item.setAttribute("data-state", selected ? "active" : "inactive");
      if (panel) {
        panel.hidden = !selected;
        panel.dataset.state = selected ? "active" : "inactive";
      }
    }
    next.dispatchEvent(
      new CustomEvent("markas-change", {
        detail: next.dataset.markasTab,
        bubbles: true,
      }),
    );
  }

  document.addEventListener("click", (event) => {
    const tab = tabOf(event.target);
    if (tab) select(tab);
  });

  document.addEventListener("keydown", (event) => {
    const tab = tabOf(event.target);
    if (!tab) return;
    const tabs = [...tab.parentElement!.children] as HTMLButtonElement[];
    const index = tabs.indexOf(tab);
    const targets: Record<string, HTMLButtonElement | undefined> = {
      ArrowRight: tabs[(index + 1) % tabs.length],
      ArrowLeft: tabs[(index - 1 + tabs.length) % tabs.length],
      Home: tabs[0],
      End: tabs[tabs.length - 1],
    };
    const target = targets[event.key];
    if (!target) return;
    event.preventDefault();
    select(target);
    target.focus();
  });
</script>
```

```astro
---
import Tabs from "@/components/markas/Tabs.astro";

const items = [
  { value: "account", label: "Account" },
  { value: "password", label: "Password" },
];
---

<Tabs items={items} defaultValue="account">
  <Fragment slot="account">Change your account name and email.</Fragment>
  <Fragment slot="password">Change your password regularly.</Fragment>
</Tabs>
```

A small client script handles clicks and the arrow keys. The selected tab dispatches a bubbling `markas-change` event with its value as `detail`.

### Angular

Save at `src/app/markas/tabs.component.ts`. No extra dependencies.

```ts
import { NgTemplateOutlet } from "@angular/common";
import {
  ChangeDetectionStrategy,
  Component,
  computed,
  contentChildren,
  Directive,
  inject,
  input,
  model,
  TemplateRef,
} from "@angular/core";

const root = "w-full";
const list = "inline-flex items-center gap-1 rounded-lg bg-subtle p-1";
const tab =
  "inline-flex h-8 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap text-muted transition-colors duration-150 ease-out hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=active]:bg-surface data-[state=active]:text-ink motion-reduce:transition-none";
const panel =
  "mt-4 rounded-md text-sm text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary";

export type TabItem = { value: string; label: string };

let nextId = 0;

/** Panel content for the tab with the same value: `<ng-template markasTabPanel="account">`. */
@Directive({ selector: "ng-template[markasTabPanel]" })
export class TabPanel {
  readonly value = input.required<string>({ alias: "markasTabPanel" });
  readonly template = inject(TemplateRef);
}

/**
 * Host stays out of layout (display: contents); id and class move to the root div.
 * The active tab supports two-way binding: `[(value)]`.
 */
@Component({
  selector: "markas-tabs",
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [NgTemplateOutlet],
  host: { class: "contents", "[attr.id]": "null" },
  template: `
    <div [id]="tabsId()" [class]="rootClasses()">
      <div
        role="tablist"
        aria-orientation="horizontal"
        [class]="list"
        (keydown)="handleKeydown($event)"
      >
        @for (item of items(); track item.value) {
          <button
            type="button"
            role="tab"
            [id]="tabsId() + '-tab-' + item.value"
            [attr.aria-controls]="tabsId() + '-panel-' + item.value"
            [attr.aria-selected]="item.value === active() ? 'true' : 'false'"
            [attr.tabindex]="item.value === active() ? 0 : -1"
            [attr.data-state]="item.value === active() ? 'active' : 'inactive'"
            [class]="tab"
            (click)="select(item.value)"
          >
            {{ item.label }}
          </button>
        }
      </div>
      @for (item of items(); track item.value) {
        <div
          role="tabpanel"
          [id]="tabsId() + '-panel-' + item.value"
          [attr.aria-labelledby]="tabsId() + '-tab-' + item.value"
          tabindex="0"
          [attr.data-state]="item.value === active() ? 'active' : 'inactive'"
          [hidden]="item.value !== active()"
          [class]="panel"
        >
          <ng-container [ngTemplateOutlet]="templateFor(item.value)" />
        </div>
      }
    </div>
  `,
})
export class Tabs {
  readonly items = input.required<TabItem[]>();
  readonly defaultValue = input<string>();
  readonly id = input<string>();
  readonly userClass = input("", { alias: "class" });
  /** Active tab. Emits valueChange on every change, so `[(value)]` works. */
  readonly value = model<string>();

  protected readonly list = list;
  protected readonly tab = tab;
  protected readonly panel = panel;
  private readonly panels = contentChildren(TabPanel);
  private readonly generatedId = `markas-tabs-${nextId++}`;
  protected readonly tabsId = computed(() => this.id() ?? this.generatedId);
  protected readonly rootClasses = computed(() =>
    [root, this.userClass()].filter(Boolean).join(" "),
  );
  protected readonly active = computed(
    () => this.value() ?? this.defaultValue() ?? this.items()[0]?.value,
  );

  protected templateFor(value: string) {
    return (
      this.panels().find((item) => item.value() === value)?.template ?? null
    );
  }

  protected select(value: string) {
    this.value.set(value);
  }

  protected handleKeydown(event: KeyboardEvent) {
    const keys = this.items().map((item) => item.value);
    const index = keys.indexOf(this.active() ?? "");
    const targets: Record<string, string | undefined> = {
      ArrowRight: keys[(index + 1) % keys.length],
      ArrowLeft: keys[(index - 1 + keys.length) % keys.length],
      Home: keys[0],
      End: keys[keys.length - 1],
    };
    const target = targets[event.key];
    if (target === undefined) return;
    event.preventDefault();
    this.select(target);
    document.getElementById(`${this.tabsId()}-tab-${target}`)?.focus();
  }
}
```

```ts
import { Component, signal } from "@angular/core";
import { TabPanel, Tabs } from "./markas/tabs.component";

@Component({
  selector: "app-settings",
  imports: [Tabs, TabPanel],
  template: `
    <markas-tabs [items]="items" [(value)]="active">
      <ng-template markasTabPanel="account">
        Change your account name and email.
      </ng-template>
      <ng-template markasTabPanel="password">
        Change your password regularly.
      </ng-template>
    </markas-tabs>
  `,
})
export class Settings {
  readonly active = signal("account");
  readonly items = [
    { value: "account", label: "Account" },
    { value: "password", label: "Password" },
  ];
}
```

Each panel is an `<ng-template markasTabPanel="value">`, so its content is only created when Angular renders that panel.

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `Blade: array<key, label> · React and Svelte: { value, label, content }[] · Vue, Astro, Angular: { value, label }[]` | [] | List of tabs. In Blade, Vue, and Astro, fill each panel through a slot named after its key or value. In Angular, use <ng-template markasTabPanel="value">. In Svelte, content is text or a snippet. |
| `defaultValue` | `string` | first tab | Tab that is active on first render. |
| `v-model / onValueChange` | `string` | - | Vue uses v-model, React uses the onValueChange callback. |
| `bind:value` | `string` | - | Svelte only. Two-way binding of the active tab. Svelte also accepts onValueChange. |
| `[(value)] / valueChange` | `model<string>` | - | Angular only. Active tab with two-way binding; valueChange emits on every change. |
| `markas-change` | `CustomEvent<string>` | - | Astro only. Bubbling event dispatched from the selected tab with its value as detail. |

## Accessibility

- Uses the tablist, tab, and tabpanel roles with aria-selected, aria-controls, and aria-labelledby.
- Left and right arrows move between tabs (wrapping at the ends), Home and End jump to the first and last tab.
- Only the active tab is in the Tab order (roving tabindex), so the next Tab moves into the panel.

## Notes

- Tab keys become ids and slot names, so use only lowercase letters, digits, or underscores.
- Tabs has no built-in text. Tab labels come from `items`, so pass them in your site's language.
