Download the PHP package ducrot/twigcn-bundle without Composer
On this page you can find all versions of the php package ducrot/twigcn-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package twigcn-bundle
TwigcnBundle
Read-only mirror. This repository is a subtree split of
ducrot/twigcnand exists so Composer/Packagist can ship the bundle. Issues and pull requests are intentionally disabled here — please open them in the main repository.
Beautiful, accessible UI components for Symfony & Twig. Inspired by shadcn/ui, built for Symfony.
Requirements
- PHP 8.2+
- Symfony 7.0+
- Node.js 22+ (for asset compilation)
- Tailwind CSS 4.0+
Installation
Step 1: Install the PHP Bundle
The bundle registers automatically via Symfony Flex.
Step 2: Install the NPM Package
If your project uses AssetMapper (the Symfony 7.x webapp default), also
expose the package to the importmap so it can be imported from JavaScript:
Webpack Encore projects pick up node_modules automatically and do not need
this step.
Step 3: Configure Your CSS
Tailwind processes a source file into a static stylesheet. Keep the source
out of assets/ (so AssetMapper does not also serve it raw) — for example
tailwind.css at the project root:
Then build with the Tailwind CLI (Symfony does not bundle CSS itself):
The compiled output at assets/styles/app.css is what AssetMapper or Encore
serves. Re-run the build whenever templates or styles change (or use
--watch during development).
Step 4: Register Stimulus Controllers
Option A: Automatic (Symfony UX)
Create or update assets/controllers.json:
Option B: Manual Registration
In a Symfony project that uses StimulusBundle (the default in the webapp
recipe), register the controllers on the existing Stimulus application from
assets/bootstrap.js (or assets/stimulus_bootstrap.js) — do not start a
second one:
For non-Symfony or fully custom Stimulus setups (e.g. Webpack Encore without StimulusBundle):
Alternative: Vite via pentatrion/vite-bundle
For projects that prefer a real bundler (recommended for Tailwind + TypeScript
- Stimulus), use
pentatrion/vite-bundletogether withvite-plugin-symfonyand@tailwindcss/vite. This is the setup the demo app in this repository uses. Vite replaces both the Tailwind CLI build (Tailwind 4 runs as a Vite plugin) and the StimulusBundle controller registration (vite-plugin-symfonyprovides its own Stimulus integration).
Install (replaces Steps 2–4 above):
vite.config.ts:
assets/app.ts:
assets/app.css:
In your base Twig template:
Then npm run dev for HMR or npm run build for production. The bundle's
config/packages/pentatrion_vite.yaml
in the demo shows the minimal Symfony-side configuration.
Usage
Components are namespaced under Twigcn: in Twig (Symfony UX TwigComponent prefixes third-party bundle components with their bundle namespace):
Available Components
Form
Button- Clickable button with variantsButtonGroup- Group of related buttonsCheckbox- Checkbox inputChoiceCard- Selectable card-style optionCombobox- Autocomplete input with suggestionsCustomSelect- Enhanced select with searchField- Form field wrapperForm- Form containerInput- Text input fieldInputGroup- Input with prefix/suffix slotsLabel- Form labelRadio/RadioGroup- Radio buttonsSelect- Native select dropdownSlider- Range sliderSwitch- Toggle switchTextarea- Multi-line text input
Layout
Accordion/AccordionItem- Collapsible sectionsBreadcrumb/BreadcrumbItem/BreadcrumbSeparator- Breadcrumb navigationCard- Container with border and shadowPagination/PaginationItem- Page navigationSidebar- Collapsible sidebar navigation (withSidebarHeader,SidebarContent,SidebarFooter,SidebarGroup,SidebarMenu,SidebarMenuItem,SidebarMenuButton)Table- Data tableTabs/TabsList/TabsTrigger/TabsContent- Tabbed content panels
Overlay
Command- Command palette (withCommandInput,CommandList,CommandGroup,CommandItem,CommandShortcut,CommandSeparator,CommandEmpty)Dialog- Modal dialog (use:closeOnBackdrop="false"for alert-dialog behavior)Drawer- Slide-out panel (withDrawerTrigger,DrawerContent,DrawerHeader,DrawerFooter,DrawerClose)DropdownMenu/DropdownMenuTrigger/DropdownMenuContent/DropdownMenuItem- Dropdown menuPopover/PopoverTrigger/PopoverContent- Floating content on triggerTooltip- Hover tooltip
Feedback
Alert- Alert messagesAvatar- User avatarBadge- Status badgesCarousel- Image/content carousel (withCarouselContent,CarouselItem,CarouselNext,CarouselPrevious)Empty- Empty-state placeholderItem- Generic content itemKbd- Keyboard key displayProgress- Progress barSkeleton- Loading placeholderSpinner- Loading spinnerThemeSwitcher- Dark/light mode toggleToast/Toaster(withToastTitle,ToastDescription,ToastClose) - Toast notifications
Naming Notes
A few PHP class names differ from their Twig component tag because the tag name is reserved or already taken in PHP:
| Twig tag | PHP class |
|---|---|
<twig:Twigcn:Empty> |
EmptyState |
<twig:Twigcn:Switch> |
SwitchComponent |
<twig:Twigcn:Field> |
FieldForm |
Theming
Components use CSS custom properties for theming. Override these in your CSS:
Dark Mode
Toggle dark mode by adding/removing the dark class on the <html> element:
Or manually:
Contributing & Issues
Development happens in ducrot/twigcn.
Open issues at https://github.com/ducrot/twigcn/issues and pull requests
against the same repo. Release notes are tracked in the monorepo's
CHANGELOG.
License
MIT License
All versions of twigcn-bundle with dependencies
symfony/config Version ^7.0
symfony/dependency-injection Version ^7.0
symfony/http-kernel Version ^7.0
symfony/ux-twig-component Version ^2.18
symfony/ux-icons Version ^2.18