Custom Alpine.js plugins and magic properties.
npm install @cboone/alpine-plugins tippy.js lightgalleryNote: This package is published to GitHub Packages. Configure your .npmrc:
@cboone:registry=https://npm.pkg.github.com
import Alpine from "alpinejs";
import { registerPlugins } from "@cboone/alpine-plugins";
registerPlugins(Alpine);
Alpine.start();If you don't need the gallery plugin:
import Alpine from "alpinejs";
import { registerPlugins } from "@cboone/alpine-plugins";
registerPlugins(Alpine, { lightgallery: false });
Alpine.start();import Alpine from "alpinejs";
import { tippyPlugin } from "@cboone/alpine-plugins";
Alpine.plugin(tippyPlugin);
Alpine.start();import Alpine from "alpinejs";
import clipboard from "@cboone/alpine-plugins/magics/clipboard";
Alpine.plugin(clipboard);
Alpine.start();Dropdown menus, navigation toggles, and tooltips using Tippy.js.
Creates a dropdown menu from a template.
<div x-data>
<button x-dropdown>Menu</button>
<template x-ref="dropdown">
<menu>
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
</menu>
</template>
</div>With options:
<button x-dropdown="{ placement: 'bottom-end' }">Menu</button>With role modifier:
<button x-dropdown:navigation>Menu</button>Specialized dropdown for mobile navigation.
<div x-data>
<button x-navbar-toggle>☰</button>
<template x-ref="navbar-menu">
<nav>...</nav>
</template>
</div>Tooltips with optional placement and follow cursor.
<button x-tooltip="'Click to submit'">Submit</button>
<button x-tooltip:top="'Tooltip on top'">Hover</button>
<span x-tooltip.followcursor="'Follows cursor'">Hover me</span>Export for programmatically hiding all Tippy instances:
import { hideAll } from "@cboone/alpine-plugins";
document.addEventListener("keydown", (event) => {
if (event.key === "Escape") {
hideAll();
}
});Photo/video lightbox galleries.
Creates a gallery from child elements with .gallery-image class.
<div x-data="{ galleryOpen: false }" x-gallery>
<a class="gallery-image" href="/photos/large-1.jpg">
<img src="/photos/thumb-1.jpg" alt="Photo 1" />
</a>
<a class="gallery-image" href="/photos/large-2.jpg">
<img src="/photos/thumb-2.jpg" alt="Photo 2" />
</a>
</div>The galleryOpen state tracks whether the gallery is open:
<body :inert="galleryOpen" :aria-hidden="galleryOpen">Copy text to clipboard.
<button @click="$copyToClipboard('Text to copy')">
Copy
</button>Remove all elements with x-ref="placeholder".
<div x-init="$removePlaceholders()">
<div x-ref="placeholder">Loading...</div>
<div>Real content</div>
</div>Scroll to top and update URL to remove hash.
<button @click="$scrollToTop()">Back to top</button>alpinejs^3.0.0 (required)tippy.js^6.0.0 (required)lightgallery^2.0.0 (optional)
MIT