Skip to content

Powered by Grav

Tabs

Tabs

Tabs organize content into switchable panels. With the sync-labels feature, tabs with matching labels stay synchronized across your entire documentation site.

Basic Tabs

Simple tabs without synchronization:

This is the preview content.

MARKDOWN
[doc-tabs]
[doc-tab title="Preview"]
This is the preview content.
[/doc-tab]
[doc-tab title="Code"]
This is the code content.
[/doc-tab]
[/doc-tabs]

Synced Tabs

Add sync-labels=true to synchronize tabs with matching labels. When you click a tab, all other synced tab groups on the page (and across pages) with the same label will switch too.

Try it: Click on JavaScript, HTML, or CSS below, then scroll down to see the other examples sync automatically.

Example 1: Installation

JAVASCRIPT
// Install via npm
npm install my-library

// Import in your code
import { myFunction } from 'my-library';

myFunction();

Example 2: Configuration

JAVASCRIPT
// Configure with JavaScript
const config = {
  theme: 'dark',
  language: 'en',
  debug: false
};

myLibrary.init(config);

Example 3: Usage

JAVASCRIPT
// Using the JavaScript API
const element = document.querySelector('#my-element');

myLibrary.animate(element, {
  duration: 300,
  easing: 'ease-out'
});

How Sync Works

When sync-labels=true is set:

  1. On click: The selected tab label is saved to localStorage
  2. On page load: Tabs check localStorage and activate matching labels
  3. Cross-tab: Changes sync across browser tabs via storage events

This is perfect for:

  • Programming language selectors (JavaScript/TypeScript/Python)
  • Package manager choices (npm/yarn/pnpm)
  • Framework examples (React/Vue/Angular)
  • OS-specific instructions (macOS/Windows/Linux)

Parameters

doc-tabs

Parameter Required Default Description
sync-labels No false Enable cross-page tab synchronization
active No 0 Initial active tab (0-indexed)

doc-tab

Parameter Required Default Description
title Yes The tab label displayed in the tab bar

Mixed Content

Tabs can contain any markdown content:

Plain text content with bold and italic formatting.

  • Lists work too
  • Multiple items

© 2025 Grav. All rights reserved.