npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

alpine-teleport

v1.0.1

Published

A teleport plugin for Alpine. Similar to Vue.js teleport component

Downloads

136

Readme

Alpine teleport

A Vue style teleport for Alpine.js

Alpine teleport is an attempt to add a Vue style teleport functionality to Alpine.js.

The primary motivation behind the plugin is to create accessible dialogs and place them at the top level within the HTML body.

Demo

Checkout the demo dialog modal component built using alpine, alpine-teleport and tailwindcss.

Usage

You can either use the plugin from CDN via the script tag or import it as a standard package by installing it from npm.

CDN

When using the CDN build, you must place the plugin script before the alpine core script.

<!-- Teleport plugin -->
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>

<!-- Alpine Core -->
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>

Npm module

Make sure first to install the package from the npm registry and then use it as follows.

npm i alpine-teleport
import Alpine from 'alpinejs'
import teleport from 'alpine-teleport'

Alpine.plugin(teleport)

x-teleport

The x-teleport directive accepts only one argument, i.e., the DOM node inside which the contents should be teleported. Thus, the DOM node should be present in the DOM when x-teleport is evaluated.

<div x-data="{ username: '' }">
  <input type="text" x-model="username" />

  <template x-teleport="#teleport-container">
    <div>
      <h2> Preview </h2>
      <p x-text="username"></p>
    </div>
  </template>
</div>

<div id="teleport-container">
  <h2>Teleport container</h2>
</div>
  • The x-teleport directive can only be used with a template tag.

  • The contents within the template tag must be wrapped inside a single root node. In other words:

    <!-- ❌ Will not work -->
    <template x-teleport="#teleport-container">
      <h2> Preview </h2>
      <p x-text="username"></p>
    </template>
    <!-- ✅ Works like a charm -->
    <template x-teleport="#teleport-container">
      <div>
        <h2> Preview </h2>
        <p x-text="username"></p>
      </div>
    </template>

Warnings

The following is the list of warnings raised by the x-teleport directive.

"x-teleport" can only be used with a template tag

The warning is raised when the x-teleport directive is used on a DOM element other than the template tag.

<!-- ✅ Valid -->
<template x-teleport="#teleport-container">
</template>

<!-- ❌ Invalid -->
<div x-teleport="#teleport-container">
</div>

"x-teleport" contents must have a single root node

The warning is raised when the x-teleport template tag has more than one root element. The fix is to wrap all the elements inside a parent div.

<!-- ✅ Valid -->
<template x-teleport="#teleport-container">
  <div>
    <h2> Preview </h2>
    <p x-text="username"></p>
  </div>
</template>

<!-- ❌ Invalid -->
<template x-teleport="#teleport-container">
  <h2> Preview </h2>
  <p x-text="username"></p>
</template>

"x-teleport" cannot locate the target DOM node

The warning is raised when we cannot find a DOM node with the selector expression passed to x-teleport.

Make sure you are using a valid query selector, or manually verify that the DOM node with the same selector exists. document.querySelector(yourExpression) should be able to locate the DOM node.