Skip to content

Getting started ​

Statamic Tabs adds two fieldtypes to Statamic:

  • Tab (type: tab) starts a tab. Every field after it belongs to that tab, up to the next Tab field.
  • Tabs End (type: tabs_end) ends the tabs. The fields after it show normally again.

That's the whole idea. Tabs only change how the publish form looks: your fields are not nested or scoped, so their values are saved, localized, validated and used in templates exactly as before. You can add tabs to an existing blueprint, or remove them again, without touching any content.

Some typical uses:

  • Split a long product or page blueprint into Content, Media and SEO tabs.
  • Give a busy Bard or Replicator set its own Content / Style / Advanced tabs.
  • Tidy up the sidebar with Pricing and Stock tabs.
  • Ship a reusable fieldset that brings its own tabs.

Requirements ​

Version
PHP8.3 or newer
Statamic6
Statamic versionAdd-on versionBranch
Statamic 3, 4, 51.x1.x
Statamic 62.xmain

Installation ​

bash
composer require eminos/statamic-tabs

The add-on registers itself, and there is nothing to publish or configure. In the blueprint editor you'll find Tab and Tabs End in the field picker. Their handles are tab and tabs_end.

Your first tabs ​

We'll split a product blueprint into Content, Media and SEO tabs.

1. Add Tab fields ​

In the blueprint editor, add a Tab field where each tab should start and give it a display name. That name is the tab's label. The handle can be anything unique, for example content_tab.

The blueprint editor: Tab fields (Hero text, Hero image) between the regular fields, and an imported fieldsetThe blueprint editor: Tab fields (Hero text, Hero image) between the regular fields, and an imported fieldset

Tab fields sit between your other fields. Everything below a Tab field belongs to it.

In YAML that is:

yaml
- handle: title
  field: { type: text, display: Name }
- handle: content_tab
  field:
    type: tab
    display: Content
- handle: summary
  field: { type: textarea, display: Summary }
- handle: description
  field: { type: bard, display: Description }
- handle: media_tab
  field:
    type: tab
    display: Media
- handle: gallery
  field: { type: assets, display: Gallery, container: assets }
- handle: seo_tab
  field:
    type: tab
    display: SEO
- handle: meta_title
  field: { type: text, display: Meta title }
- handle: meta_description
  field: { type: textarea, display: Meta description }

The title field comes before the first tab, so it stays above the tab bar. The tab bar appears where the first Tab field is.

2. Open an entry ​

The fields are now grouped into tabs. Click a tab to see its fields.

A product entry with Content, Media, Shipping and SEO tabs, a nested row inside Content and Pricing / Stock tabs in the sidebarA product entry with Content, Media, Shipping and SEO tabs, a nested row inside Content and Pricing / Stock tabs in the sidebar

The same idea, a little further: a nested row inside Content and tabs in the sidebar.

3. Add fields after the tabs (optional) ​

The last tab owns every field after it, to the end of the section. If some fields should show below the tabs instead, add a Tabs End field before them:

yaml
- handle: end_tabs
  field:
    type: tabs_end
- handle: internal_notes
  field: { type: textarea, display: Internal notes }

4. Your templates don't change ​

Since nothing is nested, you use the fields as always:

antlers
<h1>{{ title }}</h1>
{{ description }}
{{ gallery }}<img src="{{ url }}" alt="{{ alt }}">{{ /gallery }}

Tab and Tabs End fields don't store a value.

Next steps ​

Released under the MIT License. Made with fruit by kiwikiwi