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

@jimmyverburgt/svelte-input-otp

v0.5.11

Published

One time passcode Input for svelte. Accessible & unstyled.

Downloads

841

Readme

Svelte-Input-Otp

A unstyled & accessible OTP component for svelte

Installation

npm install @jimmyverburgt/svelte-input-otp

Implementation

An example of the code used to create the OTP component you can see on the website. This is using tailwind css and using the theme system from shadcn/ui

<script lang="ts">
	import { OTPInput, OTPRoot } from '@jimmyverburgt/svelte-input-otp';
	import Minus from 'lucide-svelte/icons/minus';

	// Set default value if you want to
	let value = $state('12');

	function handleOtpComplete(code: string) {
		console.log('OTP Complete:', code);
	}

	function handleOtpChange(event: { detail: string }) {
		console.log('OTP changed:', event.detail);
	}
</script>

<OTPRoot
	maxLength={6}
	ariaLabel="Svelte OTP Code"
	on:change={handleOtpChange}
	bind:value
	autoFocus={true}
	onComplete={handleOtpComplete}
	className="flex items-center gap-2"
>
	{#snippet children({ fields })}
		<div class="flex items-center">
			{#each fields.slice(0, 3) as field, index (index)}
				<OTPInput
					{field}
					className="relative flex w-10 md:w-16 h-14 md:h-20 items-center justify-center border-y border-r border-input text-3xl transition-all first:rounded-l-md first:border-l last:rounded-r-md"
					focusClassName="z-10 ring-2 ring-ring ring-offset-background"
				/>
			{/each}
		</div>
		<div class="mx-1">
			<Minus />
		</div>
		<div class="flex items-center">
			{#each fields.slice(3, 6) as field, index (index)}
				<OTPInput
					{field}
					className="relative flex w-10 md:w-16 h-14 md:h-20 items-center justify-center border-y border-r border-input text-3xl transition-all first:rounded-l-md first:border-l last:rounded-r-md"
					focusClassName="z-10 ring-2 ring-ring ring-offset-background"
				/>
			{/each}
		</div>
	{/snippet}
</OTPRoot>

API Reference

OTPRoot

The root container. Define settings for the input via props.

export type rootProps = {
	/**
	 * The input otp value from the hidden input
	 */
	value?: string;

	/**
	 * The input name value. If the OTP component is placed inside a form element. The value can be retrieved using this name
	 *
	 * @default otp
	 */
	inputName: string;

	/**
	 * The max length which is set to the hidden input. Make sure this is the same as the number of input slots.
	 */
	maxLength: number;

	/**
	 * Set if the entire input otp component needs to be disabled
	 *
	 * @default false
	 */
	disabled: boolean;

	/**
	 * Whether you want to focus the input on mount
	 *
	 * @default false
	 */
	autoFocus: boolean;

	/**
	 * Holds the children with their data
	 */
	children: Snippet<[inputSnippetProps]>;

	/**
	 * Virtual keyboard appearance on mobile
	 *
	 * @default numeric
	 */
	inputMode: 'numeric' | 'text' | 'decimal' | 'tel' | 'search' | 'email' | 'url';

	/**
	 *  Set the regexpattern for allowing only digits, only chars, or both
	 *
	 * @default digits
	 */
	pattern: 'digits' | 'chars' | 'digitsAndChars';

	/**
	 * The function that is called when the input otp is correctly filled in.
	 * @param code
	 * @returns
	 */
	onComplete?: (code: string) => unknown;

	/**
	 * @todo Add this functionality
	 */
	// pushPasswordManagerStrategy?: "increase-width" | "none";

	/**
	 * Insert your classes for the component here.
	 */
	className?: string;

	/**
	 * Add support for screen reader to this control
	 */
	ariaLabel?: string;
};

OTPInput

The input container. Define settings for the individual inputs via props.

export type inputProps = {
	/**
	 * Holds the values for the individual input fields
	 */
	field: {
		char: string | null;
		isActive: boolean;
	};

	/**
	 * Insert your classes for the component here.
	 */
	className?: string;

	/**
	 * Insert your classes for the component here when the component is focussed.
	 */
	focusClassName?: string;
};

Snippet

The snippet data.

export type inputSnippetProps = {
	/**
	 * Holds all the fields and their data
	 */
	fields: inputProps['field'][];
};

This is still a work in progress but input is welcome. Thanks