Search by

silarhi / tabler-ux-components

guillaume-sainthillier

Tabler-flavored Twig UX components for Symfony, following the shadcn composition pattern.

Package info

github.com/silarhi/tabler-ux-components

Homepage

Documentation

Language:Twig

Type:symfony-bundle

pkg:composer/silarhi/tabler-ux-components

Statistics

Installs: 773

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 3

v0.14.0 2026-11-27 15:53 UTC

README

Latest Stable Version Total Downloads License PHP Version CI Status Coverage

Tabler UX Components

Tabler-flavored Twig UX components for Symfony.
Built on the shadcn/ui composition pattern: one all-in-one tag per component, plus sub-components when you need control.

📖 Documentation

Features

  • shadcn composition: an all-in-one tag (<twig:Tabler:Card title="…" />) plus, where it makes sense, sub-components (<twig:Tabler:Card:Header>, <twig:Tabler:Card:Body>…)
  • Block-mirrored props: on composite components, each prop has a matching Twig block; override one without rewriting the rest
  • html_cva() variants: classes are declared with html_cva(), Twig's take on shadcn's CVA
  • Plain Tabler markup: Tabler / Bootstrap 5 classes; the interactive components use the data-bs-* JavaScript of tabler.js
  • Any icon: Tabler Icons from the webfont, or any icon of Symfony UX Icons with a prefixed name (icon="lucide:circle-check")
  • Attribute forwarding: extra attributes (class, id, data-*…) are merged onto the root element
  • Template-only: anonymous Twig components, no PHP classes to register or configure
  • Symfony Form themes: vertical and horizontal themes on top of Bootstrap 5, with icon, stepper, choice_style (segmented control, select group) and switch options rendered by the same components

Requirements

  • PHP 8.2+
  • Twig 3.15+ / 4.x, with twig/html-extra 3.12+ / 4.x, and Symfony UX Twig Component 2.21+ / 3.x
  • In a Symfony 6.4, 7.x or 8.x app, FrameworkBundle and TwigBundle: the bundle registers html_cva() unless TwigExtraBundle does. Without a kernel, see Without the bundle (UX Twig Component 3.2+, so PHP 8.4+)
  • Tabler 1.6+ on the front-end (1.7+ for the components that say so): its CSS, tabler.js for the interactive components, and @tabler/icons-webfont for the icons (3.36.1+ for the filled icons)
  • Optional: Symfony UX Icons 2.17+ / 3.x, for icon names with an icon set prefix (lucide:circle-check)

Installation

composer require silarhi/tabler-ux-components

On ux-twig-component v3, twig_component needs some configuration: see Installation.

Prefer to own the templates? Copy the components into your app with the Symfony UX Toolkit instead: php bin/console ux:install alert --kit=github.com/silarhi/tabler-ux-kit.

Without the bundle

From UX Twig Component 3.2, the components render in a plain Twig environment: no kernel, no symfony/dependency-injection. Add the bundle's templates/ directory to the loader, as the bundle does, and wire TwigComponent's runtime by hand, with an empty PSR-11 container for the services (the Tabler components are anonymous):

use Psr\Container\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Contracts\Service\ServiceLocatorTrait;
use Symfony\UX\TwigComponent\ComponentAttributes;
use Symfony\UX\TwigComponent\ComponentFactory;
use Symfony\UX\TwigComponent\ComponentProperties;
use Symfony\UX\TwigComponent\ComponentRenderer;
use Symfony\UX\TwigComponent\ComponentStack;
use Symfony\UX\TwigComponent\ComponentTemplateFinder;
use Symfony\UX\TwigComponent\Twig\ComponentExtension;
use Symfony\UX\TwigComponent\Twig\ComponentLexer;
use Symfony\UX\TwigComponent\Twig\ComponentRuntime;
use Twig\Environment;
use Twig\Extra\Html\HtmlExtension;
use Twig\Loader\FilesystemLoader;
use Twig\Runtime\EscaperRuntime;
use Twig\RuntimeLoader\FactoryRuntimeLoader;

// Your templates, then the bundle's: <twig:Tabler:Alert> is components/Tabler/Alert.html.twig
$loader = new FilesystemLoader([__DIR__ . '/templates', __DIR__ . '/vendor/silarhi/tabler-ux-components/templates']);

$twig = new Environment($loader, ['cache' => __DIR__ . '/var/cache/twig']);
$twig->setLexer(new ComponentLexer($twig)); // the <twig:…> syntax
$twig->addExtension(new ComponentExtension()); // {% component %}, {% props %}, component()
$twig->addExtension(new HtmlExtension()); // html_cva()
$twig->getRuntime(EscaperRuntime::class)->addSafeClass(ComponentAttributes::class, ['html']);

$services = new class([]) implements ContainerInterface {
    use ServiceLocatorTrait;
};
$propertyAccessor = PropertyAccess::createPropertyAccessor();
$dispatcher = new EventDispatcher();
$stack = new ComponentStack();
$factory = new ComponentFactory(new ComponentTemplateFinder($loader, 'components'), $services, $propertyAccessor, $dispatcher, [], [], $twig);
$renderer = new ComponentRenderer($twig, $dispatcher, $factory, new ComponentProperties($propertyAccessor), $stack);

$twig->addRuntimeLoader(new FactoryRuntimeLoader([
    ComponentRuntime::class => static fn (): ComponentRuntime => new ComponentRuntime($renderer, $services, $stack),
]));

The anonymous component directory is components, the one the bundle's templates use: your own anonymous components go in templates/components/. Without the bundle, the form themes and their options (symfony/form) and the icon names with a set prefix (lucide:check, which need UX Icons' bundle) are not available. UX Twig Component marks these classes @internal: this is the wiring of its standalone usage (symfony/ux#3602), which tests/Standalone/ checks.

Quick start

{# all-in-one #}
<twig:Tabler:Alert variant="success" title="Saved!" description="Your changes are live." />

{# composed #}
<twig:Tabler:Card>
    <twig:Tabler:Card:Header>
        <twig:Tabler:Card:Title>Danger zone</twig:Tabler:Card:Title>
        <twig:Tabler:Card:Actions>
            <twig:Tabler:Button variant="danger" size="sm">Delete</twig:Tabler:Button>
        </twig:Tabler:Card:Actions>
    </twig:Tabler:Card:Header>
    <twig:Tabler:Card:Body>This action cannot be undone.</twig:Tabler:Card:Body>
</twig:Tabler:Card>

Documentation

Every component has a live preview, its Twig source, the HTML it renders, and the reference of its props, sub-components and blocks on tabler-ux-components.silarhi.dev. Start with Composition.

Contributing

See CONTRIBUTING.md.

License

MIT License. See LICENSE for details.

Built with care by SILARHI.
If Tabler UX Components saves you time, consider giving it a star on GitHub.