Installation
composer require kevinpapst/tabler-bundle
Add to config/bundles.php:
return [
// ...
KevinPapst\TablerBundle\TablerBundle::class => ['all' => true],
];
Basic Usage Generate a new controller with the default layout:
php bin/console make:controller Admin/Dashboard --layout=tabler
Or manually extend the base template in templates/base.html.twig:
{% extends 'tabler/layout.html.twig' %}
First Component Use Tabler’s built-in components in Twig:
{{ tabler_card('Card Title', 'This is a card body') }}
docs/index.md for setup and API.TablerBundle-Demo for real-world examples.Resources/views/macros.html.twig for available macros.Default Layouts
Use the pre-built layouts (vertical or horizontal) by extending:
{% extends 'tabler/layout_vertical.html.twig' %}
Customize via Twig blocks (e.g., body, sidebar).
Dynamic Layouts
Switch layouts per route using Symfony’s layout option in routing:
# config/routes.yaml
admin_dashboard:
path: /admin
controller: App\Controller\Admin\DashboardController::index
defaults:
layout: 'tabler/layout_horizontal'
Nested Views
Leverage Twig’s embed for reusable sections (e.g., modals, alerts):
{% embed 'tabler/_partials/modal.html.twig' %}
{% block modal_title %}Confirm Action{% endblock %}
{% block modal_body %}Are you sure?{% endblock %}
{% endembed %}
Card-Based UI
Use tabler_card() for consistent cards:
{{ tabler_card('Stats', [
tabler_card_header('Total Users'),
tabler_card_body('1,234')
]) }}
Forms with Tabler Styling Extend Symfony’s form themes with Tabler classes:
{% form_theme form 'tabler/form_theme.html.twig' %}
Override templates in templates/tabler/form/ to customize inputs.
Tables & Data Grids
Use tabler_table() for responsive tables:
{{ tabler_table(users, [
{ label: 'Name', value: 'username' },
{ label: 'Role', value: 'roles|join(", ")' }
]) }}
CSS/JS Integration Bundle assets via Webpack Encore or Symfony’s asset mapper:
// webpack.config.js
Encore
.addEntry('tabler', './assets/tabler.js')
.copyFiles({
from: './vendor/kevinpapst/tabler-bundle/public',
to: 'build/[path][name].[ext]'
});
Custom Themes
Override SCSS variables in assets/scss/tabler/_variables.scss:
$tabler-primary: #6366f1; // Custom primary color
Asset Paths
composer require symfony/webpack-encore-bundle and rebuild assets:
yarn install && yarn build
Twig Macro Conflicts
tabler_card() or other macros not found.// config/bundles.php
return [
KevinPapst\TablerBundle\TablerBundle::class => ['all' => true],
// YourBundle::class => ['all' => true], // Move after TablerBundle
];
Layout Overrides
php bin/console cache:clear
templates/base.html.twig correctly extends tabler/layout.html.twig.Twig Debugging
Enable Twig debugging in .env:
TWIG_DEBUG=1
Use {{ dump(_context) }} to inspect available macros.
Component Inspection
F12) and inspect elements to verify classes (e.g., .card, .table).Custom Macros
Extend Twig macros in templates/tabler/macros.html.twig:
{% macro tabler_custom_component(content) %}
<div class="custom-component">
{{ content }}
</div>
{% endmacro %}
Layout Modifications
Override layout files in templates/tabler/ (e.g., layout_vertical.html.twig) to modify headers, footers, or sidebars.
Symfony Integration
login.html.twig, register.html.twig) with Symfony’s security component:
# config/packages/security.yaml
firewalls:
main:
form_login:
template: 'tabler/security/login.html.twig'
{{ knp_menu_render('main_menu', { template: 'tabler/_partials/nav.html.twig' }) }}
Lazy-Load Components Use dynamic imports for heavy components (e.g., charts):
// assets/tabler.js
import('tabler-chart').then(module => {
module.init();
});
Asset Optimization
base.html.twig:
<style>{{ asset('build/tabler-critical.css')|raw }}</style>
defer:
<script src="{{ asset('build/tabler.js') }}" defer></script>
Theme Variables
_variables.scss:
yarn encore dev --watch
Demo App Gaps
make:crud for data management. Replicate with:
php bin/console make:crud User
Symfony 6+ Gotchas
public/ is symlinked:
php bin/console assets:install public
How can I help you explore Laravel packages today?