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 🙏

© 2024 – Pkg Stats / Ryan Hefner

labeled-input

v3.0.2

Published

Web component as input with animated label and underline

Downloads

14

Readme

Labeled Input language

:books: Table of Contents

:dizzy: Working example

You can try this here.

:package: Installation

Include this as a module via CDN

I recommend using this as a module via CDN, which is the way I intended to use this for my own project. Other ways might work, but I have never tested them at this point.

<script src="https://unpkg.com/labeled-input" type="module"></script>

:rocket: Usage

<labeled-input
  id="my-input"
  font-family="serif"
  font-weight="100"
  font-size="30px"
  label-font-size="20px"
  label="Password"
  value="initial value"
  type="password"
  background-color="grey"
  input-color="white"
  underline-color="violet"
  label-color="cyan"
  underline-height="3px"
  underline-height-focused="6px"
></labeled-input>

Get the reference to the element.

const myInput = document.getElementById("my-input")

You can get the input event like below.

myInput.addEventListener("oninput", event => console.log(event.detail.value))

But unfortunately, you can't set the listener like <labeled-input oninput="getValue(this)"></labeled-input> because there's no way to set any reference to web component's attribute for now(it supports only strings for now).

You can get the value like below.

function getValue() {
  console.log(myInput.value)
}

And set the value like below.

function setValue() {
  myInput.value = "set value"
}

I removed google font loader library as of v3.0.0 because it makes this element work slower and you can use any font without it by common way.

If you still want to use google font with this element, import it like...

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@100&display=swap" rel="stylesheet">

as their tool suggests, and set it to this element like...

  <labeled-input
    font-family="'Roboto Slab', serif"
    font-weight="100"
  ></labeled-input>