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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-localid

v1.1.2

Published

Vue plugin to implement component scoped tag ids

Readme

vue-localid

Vue plugin to implement component scoped tag IDs.

Use of IDs in Vue components

Sometimes you want or need IDs in your Vue components. That might by OK if such a component is used only once within the browser DOM. However, If such a component is rendered multiple times it produces invalid HTML and possibly unexpected behaviour.

This example shows a very common HTML construct:

<form>
  <input type="checkbox" id="cb_enable_something">
  <label for="cb_enable_something">
    Enable something
  </label>
</form>

Many CSS solutions demand such a construct with a label tag next to the input tag. The only possible linkage is an ID. In this case you need IDs, but this code must never appear more than once inside your DOM.

This plugin adds a directive to automatically convert IDs and several attributes like "for" into application-unique names.
It's implemented as a fire-and-forget solution code: You can keep your id-based code and just add the directive v-localid to the corresponding tags.

Supported attributes:

  • id
  • for
  • form
  • aria-activedescendant
  • aria-controls
  • aria-describedby
  • aria-flowto
  • aria-labelledby
  • aria-owns

Installation

NPM

npm install vue-localid

Usage

Apply the plugin either globally (e.g. in your main.js file) or from a component.

import Vue from 'vue'
import Localid from 'vue-localid'
Vue.use(Localid)

If you prefer a shorter form and don't bother about mixing module syntax, you can use:

import Vue from 'vue'
Vue.use(require('vue-localid').default)

Apply the directive "localid" to tags containing "id" or "for" attributes:

<form>
  <input type="checkbox" id="cb_enable_something" v-localid>
  <label for="cb_enable_something" v-localid>
    Enable something
  </label>
</form>

This will be rendered as such:

<!-- render result -->
<form>
  <input type="checkbox" id="id_3_cb_enable_something">
  <label for="id_3_cb_enable_something">
    Enable something
  </label>
</form>

The applied number (here: 3) is the _uid member of the component instance.

Script access

You can generate compatible IDs from component scripts:

// returns the same ID as from the template id/from attributes
let myId = this.$localid.build("cb_enable_something");

However, addressing the DOM directly, especially with IDs, might be considered a Vue anti-pattern.

Extended usage

Alternate naming

If the name "localid" is in conflict with any other module or construct you can use your own name:

import Vue from 'vue'
import vuelocalid from 'vue-localid'

Vue.use(vuelocalid, { name: 'compid' })
<label for=cb_enable_something" v-compid>
let myId = this.$compid.build("cb_enable_something");

LICENSE

MIT