A Neos CMS package for integrating Alpine.js and a curated set of Alpine plugins, UI components, and custom extensions through the Carbon asset pipeline.
This package bundles the Alpine runtime, optional feature modules, and plugin-specific scripts in a configurable way so you can include only the pieces you need on a page.
- Alpine.js core integration for Neos
- Optional plugin loading for AJAX, anchor, clipboard, collapse, focus, intersect, mask, morph, persist, resize, and sort
- Optional UI components such as combobox, dialog, disclosure, listbox, menu, popover, radio, switch, and tabs
- Custom extension helpers for anchors, counters, fetch, focus, tooltip, tash, and typewriter
- Configurable page-level inclusion via Neos settings
- Support for both classic script bundles and ES module bundles
- Build pipeline powered by esbuild
The custom fetch helper measures maxAgeInSeconds from the local cache write
time, not the server's HTTP Date header. It stores timestamps in a separate
<cacheName>-timestamps cache, preserving the original responses and their metadata.
Existing entries without a valid timestamp are fetched again
when an age limit is set; maxAgeInSeconds: 0 keeps caching without an age limit.
Flushing or removing an old cache also removes its timestamps.
- Neos CMS
- Carbon.IncludeAssets
- Node.js and pnpm for local development/building of frontend assets
Install the package with Composer:
composer require carbon/alpineIf you want to enable automatic inclusion of the Alpine scripts across all pages, add the following to your Neos configuration:
Neos:
Neos:
fusion:
autoInclude:
Carbon.Alpine: trueThe default settings are defined in Configuration/Settings.Alpine.yaml.
Carbon:
Alpine:
includeOnPage: true
useModules: true
includeCSSOnPage: false
Main: true
Files:
Plugins:
Ajax: false
Anchor: false
Clipboard: false
Collapse: false
Focus: false
Intersect: false
Mask: false
Morph: false
Persist: false
Resize: false
Sort: false
UI:
Combobox: false
Dialog: false
Disclosure: false
ListBox: false
Menu: false
Popover: false
Radio: false
Switch: false
Tabs: false
Custom:
Anchor: false
Counter: false
Fetch: false
Focus: false
Tash: false
Tooltip: false
TypeWriter: falseincludeOnPage: includes the Alpine asset collection on the page automaticallyuseModules: renders the files as ES modules (.mjs) instead of classic script files (.js)includeCSSOnPage: includesMain.csson the page automatically; disabled by defaultMain: includes the main Alpine bundleFiles: enables or disables individual plugin, UI, and custom asset files
Main.css provides three x-cloak behaviors. Alpine removes the x-cloak
attribute after initialization, revealing the element unless another directive
(such as x-show) keeps it hidden.
Use plain x-cloak to hide an element visually while Alpine starts. It still
occupies its layout space, and cannot be clicked:
<div x-data="{ open: false }">
<button x-on:click="open = !open">Toggle</button>
<div x-cloak x-show="open">Hidden until Alpine initializes and opened</div>
</div>Use x-cloak="hidden" when the cloaked element should take up no layout space:
<div x-cloak="hidden">No space is reserved for this element while cloaked</div>Use x-cloak="nojs" to remove the element from layout when browser scripting
is enabled. With scripting disabled, the general x-cloak rule still hides it
visually, but leaves its layout space:
<div x-cloak="nojs">Removed from layout when scripting is enabled</div>The stylesheet is built to Resources/Public/Styles/Main.css. Set
includeCSSOnPage: true to add it to the page head through the Fusion
integration.
Once enabled, the package injects the generated script assets into the page through the Fusion integration. You can then use Alpine directives in your templates, for example:
<div x-data="{ open: false }">
<button x-on:click="open = !open">Toggle</button>
<div x-show="open">Content</div>
</div>The package is designed to work well with Carbon-based Neos frontends and keeps the asset loading flexible and explicit.
Resources/
Private/
Assets/ # Source assets for bundling
Bundled/ # Built plugin/module bundles
Fusion/ # Fusion prototypes used for script inclusion
Source/ # TypeScript/JS source files
Public/
Modules/ # ESM output
Scripts/ # Classic script output
Configuration/
Settings.Alpine.yaml
Install dependencies:
pnpm installBuild the package:
pnpm buildRun the watch mode during development:
pnpm watchThe build pipeline is configured in build.mjs and generates both script and module bundles for the public resources.
This package is distributed under the project license defined by the package configuration.
This package is part of the Carbon package ecosystem for Neos CMS.