Tabs
Accessible tabs component with keyboard navigation and ARIA tab pattern
Same BEM classes and behavior as Astro, Svelte, and Vue.
Add this component
The command below includes <strong>Tabs</strong>—run it in your project directory to install this component (and the CSS if needed). No prompts.
Choose your package manager — click a tab to select, then copy the command.
pnpm dlx rizzo-css add Tabs
Live examples
Usage
Usage
Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.
Astro Vanilla Svelte Vue React ---
import Tabs from '../components/astro/Tabs.astro';
---
<Tabs tabs={[{ id: 'one', label: 'Tab One' }, { id: 'two', label: 'Tab Two' }]} defaultTab="one">
<div slot="one"><p>Content for Tab One.</p></div>
<div slot="two"><p>Content for Tab Two.</p></div>
</Tabs>
<!-- Rizzo CSS + component script (from package or vanilla docs). -->
<div class="tabs" data-tabs>
<div class="tabs__list" role="tablist">...</div>
<div class="tabs__panel" role="tabpanel">...</div>
</div>
<script>
import { Tabs } from '$lib/rizzo';
</script>
<Tabs tabs={[{ id: 'one', label: 'Tab One' }, { id: 'two', label: 'Tab Two' }]} defaultTab="one">
{#snippet children(activeTabId)}
<p>Content for {activeTabId}</p>
{/snippet}
</Tabs>
<script setup>
import Tabs from '@/components/rizzo/Tabs.vue';
</script>
<template>
<Tabs
:tabs="[
{ id: 'one', label: 'Tab One' },
{ id: 'two', label: 'Tab Two' },
]"
default-tab="one"
>
<template #content="{ activeId }">
<p>Content for {{ activeId }}</p>
</template>
</Tabs>
</template>
import { Tabs } from './components/react';
<Tabs
tabs={[
{ id: 'one', label: 'Tab One' },
{ id: 'two', label: 'Tab Two' },
]}
defaultTab="one"
>
{(activeId) => <p>Content for {activeId}</p>}
</Tabs>
Other frameworks: Astro · Vanilla · Svelte · Vue