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

@metamorph-labs/polymorph-react

v1.0.19

Published

The React foundation of the Polymorph design system, which a consumer installs: the engine re-exported, the icon gateway, the motion presence components, the control hook, and the renderer of a screen a model writes at run time. Vendored members import th

Readme

@polymorph/react

The React foundation a consumer installs. It re-exports @polymorph/engine whole and adds the parts that only exist in React: the icon gateway, the motion presence components, the hooks, the conventions typed with React's element types, and the renderer of a screen a model writes. Components render the UI, and a consumer either links them (@polymorph/react-ui) or vendors them as source it owns (docs/consuming.md). This package stays a versioned dependency in both cases and is never edited downstream: a vendored member imports it and nothing deeper.

It contains:

  • The engine, whole. The root is export * from '@polymorph/engine': the theme engine and its tokens, the runtime, the framework-free conventions (dataAttrs, dataFlag, memberAttr, gallerySlug, CONTROL_SIZES, lawfulCells, controlKindOf) and the icon roles, and with it the engine's qr, charts and markdown subpaths, which the root re-exports too. A member imports one package, and a consumer installs one copy of the engine, which this package names as a dependency rather than bundling.
  • The conventions typed with React's element types: closed prop types (Governed, NativeProps, assertGoverned), the layout members' children (LayoutChildren; their spacing props, LayoutPatch and spacingAttrs are the engine's), the states fixture shape (ComponentStates, StateEntry), useControlRef, which hands a member and its caller one DOM node, and useDevWarning, for laws a type cannot express, with useDevWarnings for the list of warnings an engine model reports (a chart's warnings). useSupplied returns an element a member was passed, once React has loaded it. A member that reads or clones a child or a trigger calls it first, because a server component passes a client member an element as a reference that may still be loading. useAgentMember registers a member with the engine's agent registry while it is mounted, with the states and actions its spec's agent fence declares, and its functions always call the latest render's closures.
  • The icon gateway. Icon takes a semantic role from the engine's closed enum and renders GlyphSvg. src/icon/map.tsx holds the role → glyph assignment and GlyphSvg, which draws a glyph's SVG elements from the data-only lucide package. That file and its test are the only files allowed to import the icon set, so no icon library runs in the application. BrandMark draws the few third-party marks (google, microsoft, github) from the engine's brand data (BRAND_DRAWINGS), which every other framework's foundation draws in its own BrandMark.
  • The motion presence components (@polymorph/react/motion): MotionSurface, MotionPresence and MotionIndicator, on top of the engine's motion module. The subpath also re-exports that module by name, without animateTo, animateProperty and setFrame, which only the presence components call. A member names a binding from design/motion/motion.json; the engine resolves it and runs it on the browser's Web Animations API, with no animation library. The subpath is for member internals, so it is not a root export. Application code composes members and never sees a duration or a spring. See docs/motion.md.
  • The run-time screen renderer (@polymorph/react/screen): ScreenView draws a polymorph-screen/1 document a model writes, or the model's answer as text while it streams, with the members the application passes, at run time and with no build. Everything a document may do is decided by @polymorph/screen, the core every renderer shares: the walk, the fill of its inputs, its actions, the controls that follow the reader, its faults, when a streamed element is drawn (once the props it requires are written, from where the text ends: parsePartial's cut) and how a member takes its children. This subpath draws what the core resolves: each node keyed by its path and memoized on it, so a longer document, new data or the reader's input mounts nothing twice, and each inside its own error boundary. A host that reads the stream itself passes document with parsePartial's cut and open. allow and addresses (refused passes no address) are the host's list and policy, as the card and the check take them. A server renders no error boundary, so the screen is drawn inside one Suspense boundary: a member that throws on the server (renderToString, renderToPipeableStream) leaves the screen's place for the browser to draw, empty or holding fallback when the host gives one, and the page around it is still served. In the browser the same boundary shows fallback (nothing by default) while a member that is not lazy suspends, so a host's own Suspense boundary above ScreenView does not see it. useScreen and ScreenDrawing are its two halves, and componentFor is the rule a name resolves by among the members. The foundation knows no member, so the application passes them (import * as members from '@polymorph/react-ui'). The subpath is not a root export, so an application that imports the root loads none of it.

Entry points

In this repository the exports map points at source. pnpm build:packages builds dist/ (vite build, then declarations via tsc -p tsconfig.build.json), and publishConfig.exports maps the published subpaths onto it:

| Import | In-repo (exports) | Built (publishConfig.exports) | | ---------------------------------- | -------------------------- | ---------------------------------------------------------- | | @polymorph/react | src/index.ts | dist/index.js, dist/types/index.d.ts | | @polymorph/react/motion | src/motion/index.ts | dist/motion.js, dist/types/motion/index.d.ts | | @polymorph/react/screen | src/screen/index.ts | dist/screen.js, dist/types/screen/index.d.ts | | @polymorph/react/icon.module.css | src/icon/icon.module.css | — (in-repo only) | | @polymorph/react/style.css | — | dist/react.css (Icon's stylesheet, which Icon imports) |

It is published as @metamorph-labs/polymorph-react and installed as @polymorph/react (docs/consuming.md). Icon's recipe module imports the stylesheet as #stylesheet/react.css, and the imports map in package.json resolves it: to dist/react.css for a bundler, and to dist/no-stylesheet.js, an empty module, under the node condition. Every entry therefore stays importable by plain Node, and an application that renders Icon imports no stylesheet by hand. The ./style.css entry names the same file, for an application that imports it already.

The build keeps @polymorph/engine, @polymorph/screen, lucide and React external, and preserves modules so each keeps its own 'use client' directive. The presence components, the hooks and the screen renderer's drawing carry one; Icon and the entries do not, so Icon stays a server component and the engine stays out of a consumer's client bundle. The declarations name @polymorph/engine and @polymorph/screen, which the consumer resolves from their own install.

Dependencies and peers

| Peer | Range | Needed for | | -------------------- | --------- | ------------------------------------------------------ | | react, react-dom | ^19.0.0 | everything that renders (members take ref as a prop) |

Dependencies: @polymorph/engine, @polymorph/screen (loaded only by @polymorph/react/screen) and lucide (glyph data only, no components). There is no animation library. The motion engine uses the browser's.

Tests

pnpm exec vitest run packages/react/src                    # chromium via Playwright
pnpm exec vitest run packages/react/packaging.test.ts      # node: runs the real build
pnpm exec vitest run packages/react/screen-server.test.ts  # node: a screen rendered on a server

The browser tests, in the core vitest project, cover the icon gateway and BrandMark, the presence components, the control hook, the development warnings and the screen renderer. The screen renderer's tests draw with the real vocabulary, which they import by path, since the foundation does not depend on it. packaging.test.ts builds dist/ and checks that every published export resolves, the engine and the run-time core are imported rather than bundled, the screen renderer stays on its subpath, 'use client' directives survive, no undeclared package is imported, and the declarations typecheck as a strict consumer reads them. It holds packages/react/.dist-lock while it runs, so no other build of the same tree empties dist/ under its assertions.