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

ngx-json-render-material

v0.3.19

Published

Angular Material catalog for ngx-json-render: a ready-made component vocabulary for generative UI in Angular.

Readme

ngx-json-render-material

npm CI license

Angular Material catalog for ngx-json-render — a ready-made component vocabulary for generative UI in Angular, which an LLM can generate screens against, so you don't have to write one before your first generated screen.

ngx-json-render gives you the renderer. This gives you the 33 components it renders.

Install

ng add ngx-json-render-material

That adds the renderer, @json-render/core and zod at the ranges this package admits, and — when the workspace has no Angular Material yet — adds Material at your Angular version and runs Material's own ng add, which sets up the theme, typography and icon font the components need. A workspace that already has Material keeps its setup as it is.

Or by hand — pin Material to your Angular major (@angular/material@21 on Angular 21): a bare @angular/material resolves to the newest major, whose peers reject an older Angular with ERESOLVE.

npm install ngx-json-render-material ngx-json-render @json-render/core zod @angular/material@<your Angular major>

Requires Angular ≥ 20 and @json-render/core 0.20 or 0.21. Installed by hand, your app needs a Material theme and the icon font as usual — see Angular Material theming.

Bundle size: Angular Material and zod put a new app's initial bundle at about 1.3 MB raw (≈250 kB transferred), which is over the 1 MB error budget ng new writes into angular.json. Raise maximumError there, or render specs in a lazy-loaded route.

Agent skill

Using an AI coding agent (Claude Code, Cursor, Codex, …)? Install the skill that teaches it this catalog — every component, its props, its events and the validation contract — so the specs and overrides it writes match what ships:

npx skills add shteynu/ngx-json-render --skill ngx-json-render-material

The source is skills/ngx-json-render-material/SKILL.md; the renderer's skill is --skill ngx-json-render.

Use

import { Component } from '@angular/core';
import { JsonRenderer } from 'ngx-json-render';
import { materialRegistry } from 'ngx-json-render-material';

@Component({
  imports: [JsonRenderer],
  template: `<json-render [spec]="spec" [registry]="registry" />`,
})
export class AppComponent {
  readonly registry = materialRegistry;
  readonly spec = {
    root: 'card',
    elements: {
      card: { type: 'Card', props: { title: 'Revenue' }, children: ['total'] },
      total: { type: 'Metric', props: { label: 'Q3', value: '$1.2M', delta: '+8%', trend: 'up' }, children: [] },
    },
  };
}

To generate specs, feed the catalog's prompt to the model:

import { materialCatalog } from 'ngx-json-render-material';

const systemPrompt = materialCatalog.prompt();

On a server, import it from ngx-json-render-material/catalog instead. That entry point holds the catalog without the components, so it loads no Angular, and plain Node or an edge function can describe the vocabulary to a model and validate what comes back:

import { materialCatalog } from 'ngx-json-render-material/catalog';

Components

| Group | Components | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------- | | Layout | Stack, Grid, Card, Toolbar, ExpansionPanel, Tabs, Tab, Stepper, Step, Divider | | Typography | Heading, Text, Icon, Image | | Data display | Metric, Chip, List, ListItem, Table | | Forms | Button, IconButton, Input, Textarea, Select, DatePicker, Checkbox, RadioGroup, ToggleGroup, SlideToggle, Slider | | Feedback | ProgressBar, Spinner, Callout |

Props are named for what they mean, not for Material's API (variant, not mat-raised-button), so a spec written against this catalog stays portable to the other json-render renderers — and a model that has never seen Angular Material can still target it.

Two-way binding works as it does everywhere else in ngx-json-render: bind value or checked with {"$bindState": "/path"}, or {"$bindItem": "field"} inside a repeat.

{ "type": "Input", "props": { "label": "Name", "value": { "$bindState": "/name" } }, "children": [] }

The catalog declares no custom actions — the built-in setState, pushState, removeState, validateForm and submitForm cover it — so materialRegistry renders a spec with nothing else wired up.

Validation

Input, Textarea, Select, DatePicker, Checkbox, RadioGroup and ToggleGroup take a validation prop. The checks run against the state path the field's value is bound to, so validation applies only to a bound field — a literal value has no path to validate and the config is ignored.

{
  "type": "Input",
  "props": {
    "label": "Email",
    "value": { "$bindState": "/email" },
    "validation": {
      "checks": [
        { "type": "required", "message": "Email is required" },
        { "type": "email", "message": "That is not an email address" }
      ],
      "validateOn": "blur"
    }
  },
  "children": []
}

Check types: required, requiredIf, email, url, numeric, minLength, maxLength, pattern, min, max, matches, equalTo, lessThan, greaterThan. Arguments go in args, and may reference state:

{ "type": "minLength", "args": { "min": 8 }, "message": "At least 8 characters" }
{ "type": "equalTo", "args": { "other": { "$state": "/password" } }, "message": "Passwords must match" }

validateOn is "change", "blur" or "submit". It defaults to "blur" for Input and Textarea — validating on every keystroke is noisy — and to "change" for Select, DatePicker, Checkbox, RadioGroup and ToggleGroup, where a change is a deliberate choice. enabled takes a visibility condition and switches the whole config off when it is false.

The built-in validateForm action validates every bound field at once, regardless of validateOn, and writes the outcome to /formValidation (or the statePath you pass):

{ "type": "Button", "props": { "label": "Save" },
  "on": { "press": { "action": "validateForm" } }, "children": [] }
// /formValidation after a failed submit
{ "valid": false, "errors": { "/email": ["Email is required"] } }

submitForm does the same check and then dispatches your own action, but only if every field passed — one binding instead of a validation the button cannot act on:

{ "type": "Button", "props": { "label": "Save" },
  "on": { "press": { "action": "submitForm", "params": { "action": "saveUser" } } },
  "children": [] }

Errors appear in the Material form field's subscript (<mat-error>) for Input, Textarea, Select and DatePicker, and on their own line under Checkbox, RadioGroup and ToggleGroup, which have no form field to host one.

Two things worth knowing:

  • On Input, the required prop only draws the asterisk. Enforcement comes from a required check in validation — which also draws the asterisk, so in practice you only need validation.
  • required rejects null, undefined, empty strings and empty arrays, but not false. For a checkbox that must be ticked, use { "type": "equalTo", "args": { "other": true }, "message": "…" }.

Overriding a component

materialComponents is the plain catalog-name → component map, so swapping one entry keeps the rest:

import { defineRegistry } from 'ngx-json-render';
import { materialCatalog, materialComponents } from 'ngx-json-render-material';
import { BrandedCard } from './branded-card';

export const { registry } = defineRegistry(materialCatalog, {
  components: { ...materialComponents, Card: BrandedCard },
  actions: {},
});

Type the replacement's props with MaterialProps, so they are the ones the catalog declares for that component — every field optional, because the renderer checks them against the schema only when validate is on:

export class BrandedCard {
  readonly ctx = injectRenderContext<MaterialProps<'Card'>>();
}

Notes

  • Tabs discovers its tabs from Tab children in the spec rather than through @ContentChildren, which a spec-driven tree cannot satisfy. Each Tab hands its label and body to the parent, which replays them into real <mat-tab> elements.
  • Select with multiple: true holds an array of the chosen values; start its state as []. A required check fails on an empty array. A lone string reads as a one-item list, and an array in a select without multiple reads as no value.
  • Stepper takes Step children the way Tabs takes Tab ones. Each step but the first gets a Back button and each but the last a Next button (backLabel and nextLabel rename them). Next validates the bound fields inside its step, however deeply nested, and moves on only when they all pass; put the final submitForm button in the last step. linear: true stops the headers from skipping to a step not reached through Next. selected, the 0-based index of the open step, can be bound with $bindState to read or drive it; an index past the last step opens the last one.
  • ToggleGroup is a Material button-toggle group: a row of 2–5 segments with one chosen, bound like a RadioGroup. An option may carry an icon.
  • DatePicker keeps its date in state as a "YYYY-MM-DD" string, and so do min and max; clearing the field writes "". ISO dates compare correctly as strings, so an end date after a start date is a greaterThan check with { "other": { "$state": "/start" } }. It uses the app's DateAdapter and MAT_DATE_FORMATS when the app provides them (provideLuxonDateAdapter(), provideDateFnsAdapter(), a MAT_DATE_LOCALE), and the native Date adapter otherwise, so it needs no provider of its own.
  • Table takes columns and rows as props. Bind rows to a state array with {"$state": "/path"} rather than using repeat.
  • Image renders only an absolute https: URL and nothing for any other src — javascript:, data:, http: and relative URLs included. The schema says so too, so checkSpec reports such a src; the component checks again at render time, because a src bound to $state is only known then. It sends no referrer. alt is required; "" marks a decorative image.
  • List requires ListItem children, and Tabs requires Tab children; the catalog descriptions say so, and the prompt carries them through to the model.

Known issue: the test runner does not exit

ng test ngx-json-render-material runs the suite correctly — 12/12 pass in well under a second — but the process then stays alive instead of exiting. This is a defect in the @angular/build:unit-test + Vitest combination, not in the catalog: the test worker is clean when the suite ends (no pending timers, no stray handles), and it is the runner process that lingers.

What the bisect actually shows, against Angular 21.2 and Vitest 4.1:

  • a spec containing nothing but expect(1).toBe(1) hangs too, as long as the rest of the project's sources are on disk — so it is not what the tests do;
  • importing ./form.components reproduces it; ./layout.components, ./content.components, ./catalog and ./registry's other dependencies do not;
  • importing all nine Material form modules on their own exits cleanly;
  • so does a file of nine plain components that use those modules in their templates;
  • so does each of JrmInput, JrmSelect and JrmSlider on its own — which rules out the effect() + viewChild() pattern the inputs use, an earlier suspect here;
  • --watch=false and isolate: true with either the forks or threads pool change nothing.

It looks like a threshold in the runner rather than any one API: only the whole of form.components.ts trips it, and nothing smaller does.

The tests do run in CI. Because the results are complete and written out before the process hangs, npm run test:material goes through scripts/run-material-tests.mjs, which asks Vitest for a JSON report, waits for the report rather than for the process, kills the runner, and exits on what the report says. A failing test, a build failure, an empty run and a suite that never finishes all fail the command.

npm run test:material

License

Apache-2.0