Tabs for switching between content panels, with WAI-ARIA keyboard navigation.
<x-markas.tabs :items="['account' => 'Account', 'password' => 'Password', 'notifications' => 'Notifications']" 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-slot:notifications>Choose which emails you want to receive.</x-slot:notifications>
</x-markas.tabs>Examples
In a card
With a form
At least 8 characters
At least 8 characters
At least 8 characters
At least 8 characters
At least 8 characters
Full width
Empty state
<x-markas.tabs :items="['open' => 'Open', 'closed' => 'Closed']" default-value="open">
<x-slot:open>
<div class="grid justify-items-center gap-2 rounded-lg border border-dashed border-line px-6 py-8 text-center">
<svg class="size-6 text-muted" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 12h-6l-2 3h-4l-2-3H2" /><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" /></svg>
<span class="text-sm font-medium text-ink">No open issues</span>
<span class="text-sm text-muted">New issues from your team will show up here.</span>
<x-markas.button size="sm" class="mt-2">New issue</x-markas.button>
</div>
</x-slot:open>
<x-slot:closed>You closed 24 issues this month.</x-slot:closed>
</x-markas.tabs>Installation
npx markasui@latest add tabspnpm dlx markasui@latest add tabsyarn dlx markasui@latest add tabsbunx --bun markasui@latest add tabs- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Install the dependency:
npm install alpinejs - Copy the component source below to
resources/views/components/markas/tabs.blade.php.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Tabs.tsx.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Tabs.vue.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/Tabs.svelte.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Tabs.astro.
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/tabs.component.ts.
Usage
<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.
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.",
},
]}
/>;<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><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.
---
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.
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.
- 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.
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.
Related components
More navigation components with the same classes in every framework.
- AccordionCollapsible sections built on native details and summary, no JavaScript needed.
- BreadcrumbTrail of the current page's location in the site hierarchy, with the current page marked by aria-current.
- CollapsibleA single section that opens and closes, built on native details and summary without JavaScript. Good for show more content.
- FooterSite footer with six layouts: link columns, centered glow, newsletter pill card, giant cropped wordmark, dark glowing call to action, and a floating pill.
- MenubarHorizontal bar of menus like a desktop app, built on the Popover API, with keyboard support following the WAI-ARIA Menubar pattern.
- NavbarSite header with a brand, links, dropdown menus, a sliding hover pill, an actions area, and a mobile menu with collapsible groups.