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

@emeryld/ui-schema-tsx

v0.1.6

Published

Standalone React DOM + TypeScript package for rendering and editing Zod v4 object schemas.

Downloads

709

Readme

@emeryld/ui-schema-tsx

Standalone React DOM + TypeScript package for rendering and editing Zod v4 object schemas.

Install

pnpm add @emeryld/ui-schema-tsx react react-dom zod

CSS

import '@emeryld/ui-schema-tsx/styles.css'

Basic usage

import { SchemaTSX, useSchemaState } from '@emeryld/ui-schema-tsx'
import { z } from 'zod'

const schema = z.object({
  name: z.string(),
  age: z.number(),
  active: z.boolean(),
})

const { value, setValue, reset, errors } = useSchemaState(
  schema,
  { age: 18 },
  {
    onValidationChange: ({ key, errors, valid }) => {
      console.log(key, errors, valid)
    },
  },
)

<SchemaTSX
  schema={schema}
  value={value}
  onChange={(nextValue) => setValue(nextValue)}
  onFieldChange={(key, nextValue) => console.log(key, nextValue)}
  onValueClick={({ rawString, key, value }) => console.log(rawString, key, value)}
  onValidationChange={(result) => console.log(result)}
/>

Derived schemas and memoization

SchemaTSX and useSchemaState are resilient to derived-schema identity churn (for example inline schema.omit(...)). For better performance, still memoize derived schemas in consumers:

const formSchema = useMemo(() => schema.omit({ hidden: true }), [schema])

Custom registry factory

import { createSchemaTSXFactory } from '@emeryld/ui-schema-tsx'

const schemaTSX = createSchemaTSXFactory({
  variants: {
    string: {
      textInput: StringTextInput,
      textarea: StringTextarea,
    },
    number: {
      textInput: NumberTextInput,
      slider: NumberSlider,
    },
  },
})

export const SchemaTSX = schemaTSX.SchemaTSX

Display map

display={{
  name: { variant: 'textarea', props: { label: 'Name' } },
  age: { variant: 'slider', props: { minValue: 0, maxValue: 100 } },
  status: { variant: 'select', props: {} },
}}

Variant conventions

Use component variants to change UX behavior, and wrapper variants to style element containers.

  • Wrapper variants define styling of elements inside a component (for example pills in a pill selector, or menu items in a dropdown).
  • Component variants define the interaction pattern/UX (for example toggle vs checkbox, or dropdown vs pill selector).
  • This separation is the expected API direction everywhere, even where older components still mix the two.

Examples of expected shape:

  • Dropdown should not own style variants. It should expose optional:
    • boxWrapperVariant (default: card)
    • menuItemWrapperVariant (default: flat)
  • Button variants should represent button UX/shape (circle, rectangular, etc.), while visual styles should come from wrapper variants and wrapper background color.

Enum options shape

Enum variants receive options as:

Array<{ value: string; label: string }>

Value handling

Interactible controls use a controlled value contract:

  • value
  • onChange

All interactive variants/components should use this pattern consistently.

Optional and nullable markers

  • ? optional
  • nullable
  • * required
  • nullable takes precedence when both wrappers exist
  • markers are shown in editable mode by default

Intersection and TrayFolder behavior

ZodIntersection is handled explicitly. Initial values are created per side and deep-merged for plain objects. Object intersections are rendered using a tray-folder style object variant, with fallback support exported as TrayFolder.

createInitialSchemaValue

import { createInitialSchemaValue } from '@emeryld/ui-schema-tsx'

const initialValue = createInitialSchemaValue(schema)

It first tries schema.safeParse(undefined) (to respect defaults/prefaults/catch/transforms), then falls back to structural generation.