Skip to content
FrameworkJavaScript

Toggle block: collapsible content

A collapsible toggle block with a clickable arrow. Child blocks are nested inside the toggle and hidden when collapsed. Toggling is controlled by clicking the arrow icon. The open/collapsed state is persisted via `isOpen` and restored on reload; toggles default to open.

Import

TypeScript
import { Toggle } from '@bloklabs/core/tools';

Configuration

OptionTypeDefaultDescription
placeholderstring"Toggle"Placeholder text shown in an empty toggle block.

Save Data

TypeScript
interface ToggleItemData {
  text: string;     // Toggle title HTML content
  isOpen?: boolean; // Whether the toggle is expanded — persisted and restored on reload
}
JSON
{
  "id": "mno345",
  "type": "toggle",
  "data": {
    "text": "Click to expand"
  }
}

Usage Example

TypeScript
import { Blok } from '@bloklabs/core';
import { Toggle } from '@bloklabs/core/tools';

const editor = new Blok({
  holder: 'editor',
  tools: {
    toggle: {
      class: Toggle,
      placeholder: 'Toggle heading…',
    },
  },
});