silarhi / tabler-ux-components
Tabler-flavored Twig UX components for Symfony, following the shadcn composition pattern.
Package info
github.com/silarhi/tabler-ux-components
Language:Twig
Type:symfony-bundle
pkg:composer/silarhi/tabler-ux-components
Requires
- php: >=8.2
- symfony/service-contracts: ^2.5 || ^3.0
- symfony/ux-twig-component: ^2.21 || ^3.0
- twig/html-extra: ^3.12 || ^4.0
- twig/twig: ^3.15 || ^4.0
Requires (Dev)
- ext-dom: *
- ext-libxml: *
- ergebnis/composer-normalize: ^2.58.0
- friendsofphp/php-cs-fixer: ^3.95.32
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.3.7
- phpstan/phpstan-strict-rules: ^2.1.2
- phpstan/phpstan-symfony: ^2.1.1
- phpunit/phpunit: ^11.5.58 || ^12.5.38 || ^13.4.1
- psr/container: ^1.1 || ^2.0
- rector/rector: ^2.9.2
- symfony/config: ^6.4 || ^7.0 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.0 || ^8.0
- symfony/error-handler: ^6.4 || ^7.0 || ^8.0
- symfony/event-dispatcher: ^6.4 || ^7.0 || ^8.0
- symfony/form: ^6.4 || ^7.0 || ^8.0
- symfony/framework-bundle: ^6.4 || ^7.0 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.0 || ^8.0
- symfony/property-access: ^6.4 || ^7.0 || ^8.0
- symfony/routing: ^6.4 || ^7.0 || ^8.0
- symfony/twig-bundle: ^6.4 || ^7.0 || ^8.0
- symfony/ux-icons: ^2.36.1 || ^3.0
- twig/extra-bundle: ^3.12 || ^4.0
- vincentlanglet/twig-cs-fixer: ^4.1.2
Suggests
- symfony/form: To use the Tabler form themes and their options (icon, stepper, choice_style, switch)
- symfony/framework-bundle: Register Silarhi\TablerUxComponents\TablerUxComponentsBundle, with symfony/twig-bundle, for zero-config wiring (optional: from symfony/ux-twig-component 3.2, a plain Twig environment renders the components without symfony/dependency-injection nor symfony/http-kernel, see the README)
- symfony/ux-icons: To render any icon of Iconify or your own SVG files with the Icon component and the icon props (names with an icon set prefix, e.g. "lucide:check")
Provides
None
Conflicts
- symfony/config: <6.4
- symfony/dependency-injection: <6.4
- symfony/http-kernel: <6.4
Replaces
None
README
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 withhtml_cva(), Twig's take on shadcn's CVA- Plain Tabler markup: Tabler / Bootstrap 5 classes; the interactive components use the
data-bs-*JavaScript oftabler.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) andswitchoptions rendered by the same components
Requirements
- PHP 8.2+
- Twig 3.15+ / 4.x, with
twig/html-extra3.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.jsfor the interactive components, and@tabler/icons-webfontfor 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.
- Feedback: Alert, Empty, Placeholder, Progress, ProgressSteps, Spinner, TextShimmer, Toast
- Actions: Button, ButtonActions, ButtonGroup, ButtonList, ButtonToolbar, Clipboard, Dropdown, SegmentedControl, SwitchIcon
- Forms: InputIcon, NumberInput, Selectgroup
- Content: Accordion, Avatar, Badge, Card, Carousel, Chat, Datagrid, Divider, Flag, Hover gallery, Icon, Image label, Kbd, List, List group, Mention, Mockup browser, Prose, Ribbon, Status, Table, Tag, Timeline
- Overlays: Modal, Offcanvas, Popover, Tooltip
- Navigation: Breadcrumb, Nav, Pagination, Step, Tabs
- Layout: Footer, Navbar, Page, PageHeader, PageSection
- Data display: Legend, Signal, Sparkline, StarRating, Tracking, Trending
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.