GCBGutenberg
Control Blocks
v1.3.3
Buy

Tabs

A strip of tabs, each opening a panel your client fills with any blocks. Stacks on a phone.

Tabs your client edits where they sit. Each tab is a block of its own with a title, typed on the canvas, and a panel that takes any blocks. On the page it is an ARIA tablist that works with the arrow keys, and it can stack into a list on a phone.

The Tabs example in the editor: your client picks a tab on the strip and edits its panel in place.
The Tabs example in the editor: your client picks a tab on the strip and edits its panel in place.

Download example A zip of block folders for your theme. Needs GCB 1.3.1 or later, and nothing else.

What's in the download

  • tabs/ The tabs block. One field sets what happens on a phone.
  • tab/ One tab: a title and a panel for any blocks.

Each folder is an ordinary GCB block: block.json, block.fields.json and render.php, plus a style.css and a view.js where it needs them. There is no build step and no library.

How it's built

The parent's template marks where the tabs go with a <Repeater>, which names the child block and sets the limits. In the editor your client sees one tab at a time with the strip above it, the same as the page.

tabs/render.php
<Repeater  allowedBlocks='["gcb/tab"]'  addButtonLabel="Add tab"  min="1"  max="12"  editLayout="tabs"/>

Its fields, from block.fields.json:

FieldType
On a phoneselect

view.js is about 2 KB of plain JavaScript. With no script, every panel shows under its title.

Use it

  1. Unzip the download.
  2. Copy tabs/ and tab/ into your theme's blocks/ folder.
  3. Reload the block editor. The block is in the inserter.

That's all of it. You don't register the block: there's no register_block_type() call and nothing to add to functions.php. GCB registers every folder in your theme's blocks/ folder by itself.

It is your block now. Change the markup, the fields or the script to suit the design. The docs cover every field type and marker used here.

More examples: all examples, or download them together as the GCB Kit.

Build anything in the block editor

Every licence includes all features and a year of updates and support.

Buy GCB from $8.25 a month See pricing