jmf/twig-tabs-bundle

Symfony bundle for rendering Bootstrap tabs in Twig templates.

Maintainers

Package info

github.com/jmfeurprier/twig-tabs-bundle

Type:symfony-bundle

pkg:composer/jmf/twig-tabs-bundle

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-05-30 15:23 UTC

This package is auto-updated.

Last update: 2026-05-30 16:39:54 UTC


README

Symfony bundle integrating jmf/twig-tabs: a Twig tabs() / tab() API that renders tabbed content in Twig templates (defaulting to Bootstrap 5 theme).

Requirements

  • PHP 8.3+
  • Symfony 7.0 or 8.0

Installation

Install with Composer:

composer require jmf/twig-tabs-bundle

If you have Symfony Flex, the tabs() / tab() functions are instantly available without further configuration. Otherwise, register the bundle in config/bundles.php:

<?php

return [
    // ...
    Jmf\TwigTabsBundle\JmfTwigTabsBundle::class => ['all' => true],
];

Quick Start

Use the tabs() and tab() functions in any Twig template:

{{ tabs(
    tab('articles').label('First tab').content('<p>Content 1</p>'),
    tab('authors').label('Second tab').include('path/to/template.html.twig', {foo: bar}),
    tab('comments').label('With badge').content('<p>Content 3</p>').badge('5'),
) }}

Or pass an array of builders:

{{ tabs(myTabBuilders) }}

tab() builder methods

Method Description
.label(string $label) Tab header label
.content(string $html) Raw HTML content for the tab pane
.include(string $path, array $parameters) Render a template as the tab pane content
.badge(?string $badge) Optional badge displayed next to the label

Configuration Reference

All settings are optional. Create config/packages/jmf_twig_tabs.yaml to override the defaults:

jmf_twig_tabs:

    # Optional prefix before the "tabs" and "tab" function names. Default: ''
    # Example: 'jmf_' registers 'jmf_tabs' / 'jmf_tab' instead of 'tabs' / 'tab'.
    prefix: ''

    # Twig template used as the rendering entry point. Default: '@JmfTwigTabs/bootstrap/tabs.html.twig'
    template_path: '@JmfTwigTabs/bootstrap/tabs.html.twig'

A sample configuration file is available in the samples/ directory.

Customising templates

The @JmfTwigTabs namespace is registered automatically and points at the Bootstrap templates shipped by jmf/twig-tabs. To customise the markup, either set template_path to your own entry point, or override the namespaced templates (tabs.html.twig, nav-tabs.html.twig, nav-item.html.twig, tab-content.html.twig, tab-pane.html.twig) from your application.

License

MIT