Skip to content

Tab rows, nesting & Tabs End ​

By default every Tab field in a section joins one row of tabs. Three tools change that:

You want…Use
a second, separate row of tabs further downStart a new tab row on its first tab
a row of tabs inside a tabNested tab on the inner tabs
fields after the tabs that don't belong to any taba Tabs End field

All three work the same in the main form, the sidebar, sets, Groups and fieldsets.

How fields are assigned ​

The add-on reads the fields of a section from top to bottom:

  1. A field before the first tab is not in a tab.
  2. A Tab field starts a tab. The fields after it belong to it, up to the next Tab (or Tabs End) field.
  3. A tab joins the current row, unless it starts a new one or is nested.
  4. A Tabs End field closes the current row. The fields after it are outside that row.

Each blueprint section (and each set, Group or Grid row) is read on its own, so tabs never reach across sections.

Tab rows ​

Turn on Start a new tab row (tab_new_row: true) on a tab to start a separate row there, instead of adding the tab to the row above. The fields between the two rows belong to the last tab of the first row.

yaml
- handle: hero_text_tab
  field: { type: tab, display: Hero text }
- handle: hero_heading
  field: { type: text, display: Heading }
- handle: hero_image_tab
  field: { type: tab, display: Hero image }
- handle: hero_image
  field: { type: assets, display: Image, max_files: 1 }
- handle: button_tab
  field:
    type: tab
    display: Button
    tab_new_row: true      # a second row starts here
- handle: button_label
  field: { type: text, display: Label }
- handle: button_style_tab
  field: { type: tab, display: Style }
- handle: button_variant
  field: { type: button_group, display: Variant, options: { primary: Primary, ghost: Ghost } }

A landing page with a Hero text / Hero image row and, below it, a separate Button / Style / Advanced rowA landing page with a Hero text / Hero image row and, below it, a separate Button / Style / Advanced row

Two rows on one form. The second row comes from an imported fieldset.

A Tabs End followed by a new Tab also starts a new row, see below.

Nested tabs ​

Turn on Nested tab (tab_nested: true) to put a tab in a row inside the preceding tab. Consecutive nested tabs form that inner row. The next tab that isn't nested continues the outer row.

yaml
- handle: content_tab
  field: { type: tab, display: Content }
- handle: summary                    # in Content, above the nested row
  field: { type: textarea, display: Summary }
- handle: description_tab
  field: { type: tab, display: Description, tab_nested: true }
- handle: description
  field: { type: bard, display: Description }
- handle: specs_tab
  field: { type: tab, display: Specifications, tab_nested: true }
- handle: specs
  field: { type: grid, display: Specifications, fields: [] }
- handle: media_tab                  # not nested: back in the outer row
  field: { type: tab, display: Media }
- handle: gallery
  field: { type: assets, display: Gallery }

The Content tab with a Summary field and, below it, a nested Description / Specifications / FAQ rowThe Content tab with a Summary field and, below it, a nested Description / Specifications / FAQ row

Content is the outer tab. Its nested row starts where the first nested tab is.

Good to know:

  • Fields between the outer tab and its first nested tab (like Summary above) stay visible in the outer tab, above the nested row.
  • A nested tab with Start a new tab row starts a second nested row inside the same outer tab.
  • One level of nesting is supported. A nested tab with no tab before it is treated as a normal tab.
  • To get back to the outer tab after a nested row, without starting another outer tab, use a Tabs End (next section).

Tabs End ​

A Tabs End field (type: tabs_end) ends the innermost open row:

  • Inside a nested row, the fields after it continue in the parent tab, below the nested row.
  • In a top-level row, the fields after it appear outside all tabs, as normal fields.

Turn on End all tab rows (including nested) (end_all: true) to close a nested row and its outer row at once, so the following fields are outside all tabs.

yaml
- handle: seo_tab
  field: { type: tab, display: SEO }
- handle: meta_title
  field: { type: text, display: Meta title }
- handle: end_tabs
  field:
    type: tabs_end           # the tabs end here
- handle: internal_notes     # shown below the tabs, whatever tab is open
  field: { type: textarea, display: Internal notes }

The Advanced tab of the Button row, and below it a Show newsletter signup toggle that is outside the tabsThe Advanced tab of the Button row, and below it a Show newsletter signup toggle that is outside the tabs

The Button fieldset ends with a Tabs End, so Show newsletter signup stays outside its Advanced tab.

A Tabs End doesn't render anything and doesn't store a value. A Tab after it starts a fresh row.

The Tabs End field settings with the End all tab rows (including nested) toggleThe Tabs End field settings with the End all tab rows (including nested) toggle

Fieldsets with tabs ​

Fieldsets can contain Tab and Tabs End fields like any other fields, so a reusable fieldset can bring its own tabs. Two habits make them easy to combine:

  1. End the fieldset with a Tabs End field. Without it, the fields that come after the import in a blueprint would land in the fieldset's last tab.
  2. Don't hard-code where the tabs go. Decide per import, with Statamic's import config (below).
yaml
# resources/fieldsets/button.yaml
title: Button
fields:
  - handle: button_tab
    field: { type: tab, display: Button, tab_icon: cursor-click }
  - handle: button_label
    field: { type: text, display: Label }
  - handle: button_url
    field: { type: link, display: Link }
  - handle: button_style_tab
    field: { type: tab, display: Style, tab_icon: palette }
  - handle: button_variant
    field: { type: button_group, display: Variant, options: { primary: Primary, ghost: Ghost } }
  - handle: button_tabs_end
    field: { type: tabs_end }

Per-import overrides ​

Statamic lets you override the config of imported fields with config, keyed by the field handle inside the fieldset. Use it to change how the fieldset's tabs fit in:

yaml
# As its own row, below the tabs that come before the import
- import: button
  config:
    button_tab:
      tab_new_row: true
yaml
# Inside the preceding tab, as a nested row
- import: button
  config:
    button_tab:
      tab_nested: true
    button_style_tab:
      tab_nested: true
yaml
# Continuing the current row (no config needed)
- import: button

The same works for a single referenced field (field: button.button_tab with config:), and with a prefix: on the import. The keys under config are always the handles from the fieldset file, without the prefix.

When you nest an imported fieldset, its Tabs End (without End all) closes only the nested row, so the fields after the import continue in the parent tab.

Released under the MIT License. Made with fruit by kiwikiwi