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

@4i4/theme-form

v0.1.8

Published

Form primitives for @4i4/theme-registry

Readme

@4i4/theme-form

Form-oriented components built on top of @4i4/theme-registry.

Installation

npm install @4i4/theme-form @4i4/theme-registry
yarn add @4i4/theme-form @4i4/theme-registry

Usage

import { FormElement } from "@4i4/theme-form";

<FormElement type="input" name="email" label="Email" />;

<FormElement
  type="select"
  name="country"
  label="Country"
  placeholder="Select country"
  options={[
    { value: "de", label: "Germany" },
    { value: "us", label: "United States" },
    { value: "au", label: "Australia" },
  ]}
/>;

FormElement looks up both field and wrapper templates within the registry using sensible defaults based on the provided type and name. When a template is missing it renders a simple diagnostic fallback component so gaps in the registry are easy to spot during development.

The optional scope prop lets you override the context key used for template lookup. By default it uses form-element, but you can specify a custom scope if your registry stores form templates under a different namespace.

Registering templates

A minimal text field template might look like this:

// TextField.tsx
import type { FormFieldProps } from "@4i4/theme-form";

type TextFieldProps = FormFieldProps;

export default function TextField({ name, ...props }: TextFieldProps) {
  return <input type="text" name={name} {...props} />;
}

A select field template can consume the same base props while rendering choices:

// SelectField.tsx
import type { FormFieldProps } from "@4i4/theme-form";

type SelectFieldProps = FormFieldProps;

export default function SelectField({ options = [], ...props }: SelectFieldProps) {
  return (
    <select {...props}>
      {options.filter(({ hidden }) => !hidden).map(({ value, label }) => (
        <option key={String(value)} value={value}>
          {label}
        </option>
      ))}
    </select>
  );
}

Each option can also declare hidden: true to keep it out of the rendered list while preserving the value for other use cases.

A minimal wrapper can decorate the resolved field while accepting additional props:

// FieldWrapper.tsx
import type { ReactNode } from "react";
import type { FieldWrapperProps } from "@4i4/theme-form";

type WrapperProps = FieldWrapperProps<{
  error?: ReactNode;
  helper?: ReactNode;
}>;

export default function FieldWrapper({
  Component,
  label,
  error,
  helper,
  type,
  name,
  id,
  ...props
}: WrapperProps) {
  const labelTemplates = [
    'label',
    `label--${type}`,
    `label--${name}`,
    `label--${type}--${name}`,
  ];

  return (
    <div>
      {label ? (
        <Template template={labelTemplates} htmlFor={id}>
          {label}
        </Template>
      ) : null}
      <Component name={name} id={id} {...props} />
      {error}
      {helper}
    </div>
  );
}