Skip to content

About

Headless, framework-agnostic behavioral primitives for specialized input fields.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

71 Commits

Folders and files

Repository files navigation

Zealakit Pattern Input

English | Tiếng Việt | 中文

Zealakit Pattern Input cover

Headless behavioral primitives for number, masked, and one-time-code input fields in Vanilla TypeScript, React, Vue, and Svelte.

  • Core — an internal shared kernel for parsing, formatting, caret state, and the one DOM binding. It is bundled inside every adapter and never published on its own.
  • Adapters — one package per framework, exposing the same prop-getter contract.
  • SSR-safe — importing a package never touches browser globals.

Pattern Input handles formatting, caret and selection, keyboard navigation, clipboard paste, IME composition, and ARIA attributes. It ships no styles and no validation engine: you own the element, the CSS, and the rules.

Note Pattern Input is a focused, headless set of primitives for number, masked, and one-time-code fields. It ships no CSS and renders no styled markup, so you keep full control of the visuals. Date pickers, currency conversion, phone-number metadata, and a validation engine are not implemented.

Pattern Input is not a replacement for a full UI library or design system. Use it when you need accessible input-field behavior without adopting a large kit, or when your current library's fields are hard to restyle.

Which field to use

Field Best for Output type Key features
Number Prices, quantities, decimals, percentages number | null Locale separators, step keys, rounding, min/max clamping
Masked Tax IDs, phone numbers, card numbers, license keys string (raw without literals) Multi-mask alternatives, selectMask, custom tokens, showLiterals
OTP 2FA codes, SMS verification, PINs string (compacted code) Per-slot focus/roving tabindex, paste distribution, hidden form input

Packages

Package Framework/Runtime Documentation
@zealakit/pattern-input-vanilla Vanilla JS / TS README
@zealakit/pattern-input-react React 18 / 19 README
@zealakit/pattern-input-vue Vue 3.5+ README
@zealakit/pattern-input-svelte Svelte 5 README

Install one adapter for your framework. Your app already provides the framework runtime, so you only add the adapter. Each adapter bundles @zealakit/pattern-input-core, which is not published to npm; you never install or configure core directly.

Installation

npm i @zealakit/pattern-input-vanilla
npm i @zealakit/ui-engine   # peer
npm i @zealakit/pattern-input-react
npm i @zealakit/ui-engine   # peer
npm i @zealakit/pattern-input-vue
npm i @zealakit/ui-engine   # peer
npm i @zealakit/pattern-input-svelte
npm i @zealakit/ui-engine   # peer

# or yarn, pnpm, ...

Status

This is 1.0.0-beta.1. All three fields (number, masked, OTP) work in every adapter, with the same prop-getter contract and conformance vectors. The packages ship no styles, no validation engine, and never wrap a plain-text input.

Behavior

Capability Number Masked OTP
Caret survives formatting and paste Yes Yes Yes
Paste parsed by the field Yes Yes Yes
IME commits once at compositionend Yes Yes Yes
Correct mobile inputmode decimal / numeric numeric or text numeric
Controlled and uncontrolled modes Yes Yes Yes
Undo / redo with caret Yes Yes Yes
ARIA (aria-invalid, labels, hidden input) Yes Yes Yes

Size

Min+gzip per adapter × field, measured with esbuild (pnpm size):

Adapter Number Masked OTP
vanilla 8.5 kB 7.6 kB 5.6 kB
react 8.7 kB 7.8 kB 5.8 kB
vue 8.4 kB 7.5 kB 5.6 kB
svelte 8.3 kB 7.4 kB 6.9 kB

Examples

The examples/ folder holds runnable integration projects for Vanilla, React, Vue, Svelte, and Next.js. They demonstrate:

  • Number input with live locale switching (de-DE / en-US / vi-VN)
  • Country-switched phone mask (US, VN, UK) without digit-shifting overflow
  • Multi-mask Tax ID (CPF 11-digit / CNPJ 14-digit) and prefix-driven selectMask payment card (Visa/MC vs Amex)
  • Custom tokens with showLiterals: "always", 6-box OTP form submission, controlled rejection, and blur validation
pnpm install
pnpm build
pnpm dev:vanilla   # or dev:react, dev:vue, dev:svelte, dev:nextjs

Agent Skills

Add the integration skill for your framework to your agent's skills directory:

License

MIT © Zealakit

About

Headless, framework-agnostic behavioral primitives for specialized input fields.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages