Skip to main content

Overview

The Tabs plugin creates tabbed content panels with theme support. Perfect for organizing related content that users can switch between.

Installation

npm install @yoopta/tabs

Basic Usage

import { useMemo } from 'react';
import YooptaEditor, { createYooptaEditor } from '@yoopta/editor';
import Tabs from '@yoopta/tabs';

const plugins = [Tabs];

export default function Editor() {
  const editor = useMemo(() => createYooptaEditor({ plugins, marks: [] }), []);
  return <YooptaEditor editor={editor} onChange={() => {}} />;
}

Features

  • Multiple Tabs: Create multiple tab panels within a single block
  • Theme Support: Built-in themes (default, success, warning, error, info)
  • Keyboard Navigation: Navigate tabs with keyboard
  • Shortcuts: Type tabs to insert

Configuration

import Tabs from '@yoopta/tabs';

const plugins = [Tabs];

Options

display
object
shortcuts
string[]
default:"['tabs']"
Keyboard shortcuts to trigger the plugin in slash menu

Element Props

tabs.props
object

Commands

Tabs commands are available via TabsCommands.

insertTabs

Insert a new Tabs block.
import Tabs, { TabsCommands } from '@yoopta/tabs';

TabsCommands.insertTabs(editor, {
  props: { theme: 'success' },
  at: 0,
  focus: true,
});
props.theme
TabsTheme
default:"default"
Theme for the tabs
at
YooptaPathIndex
Index where to insert the block
focus
boolean
Whether to focus the new block after insert

deleteTabs

Delete a tabs block.
import { TabsCommands } from '@yoopta/tabs';

TabsCommands.deleteTabs(editor, blockId);

buildTabsElements

Build tabs element structure (used internally).
import { TabsCommands } from '@yoopta/tabs';

const tabsElement = TabsCommands.buildTabsElements(editor, {
  props: { theme: 'info' },
});

Block Operations

You can also use the generic Blocks API:
import { Blocks } from '@yoopta/editor';

// Update theme
Blocks.updateBlock(editor, { blockId, meta: { ... } });

// Delete
Blocks.deleteBlock(editor, { blockId });

Element Operations

Use the Elements API to update tab properties:
import { Elements } from '@yoopta/editor';

// Update tab theme
Elements.updateElement(editor, {
  blockId,
  type: 'tabs',
  props: { theme: 'warning' },
});

Themes

The Tabs plugin supports the following themes:
  • default: Default styling
  • success: Green theme for positive/success content
  • warning: Yellow/orange theme for warnings
  • error: Red theme for errors or important notes
  • info: Blue theme for informational content

Parsers

HTML

  • Deserialize: Custom HTML structure with tabs
  • Serialize: Tabs block → <div> with tab structure and theme data attributes

Email

  • Serialize: Table-based layout for email client compatibility

Build docs developers (and LLMs) love