For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/schematics.md.

Schematics

@blotch/angular-lynx ships Angular CLI schematics that set a project up for Lynx and generate Lynx components.

SchematicCommandWhat it does
ng-addng add @blotch/angular-lynxTurns an ng new project into a Lynx app
componentng generate component <name>Generates a component with a Lynx template
add-tailwindng g @blotch/angular-lynx:add-tailwindAdds Tailwind CSS
add-testingng g @blotch/angular-lynx:add-testingAdds the AngularLynx testing library
add-i18nng g @blotch/angular-lynx:add-i18nAdds @angular/localize and provideLocale()
ejectng g @blotch/angular-lynx:ejectCopies the iOS and Android projects into your repo

npm create angular-lynx runs ng add for you. Every schematic takes --project, which defaults to the project you're in.

ng-add

ng add @blotch/angular-lynx

What it changes:

  • src/main.ts: replaced. It calls bootstrapApplication from @blotch/angular-lynx.
  • src/app/app.config.ts: replaced, with provideRenderer() and provideRouter(routes) (from @blotch/angular-lynx).
  • src/app/app.ts: replaced with a root component whose inline template uses Lynx elements and a <router-outlet>. app.html, app.css (or .scss) and app.spec.ts are deleted.
  • src/rspeedy-env.d.ts: added. It types asset and CSS module imports.
  • tsconfig.app.json excludes src/**/*.test.ts, and tsconfig.spec.json includes it.
  • angular.json:
    • build uses @blotch/angular-lynx-build:application. It keeps ng new's configurations and the options the builder accepts, and adds appName and a placeholder appId (com.example.<name>) for the native apps.
    • ng new's initial budget (500 kB warning, 1 MB error) becomes 2 MB and 5 MB. A new app's Lynx bundle is about 720 kB.
    • serve uses @blotch/angular-lynx-build:dev-server, keeping buildTarget, port and host.
    • test uses @blotch/angular-lynx-build:unit-test, keeping the options of an @angular/build:unit-test target.
    • extract-i18n uses @blotch/angular-lynx-build:extract-i18n, so ng extract-i18n works. Angular CLI can't pick an extractor for the Lynx build by itself.
    • cli.schematicCollections lists @blotch/angular-lynx first, so ng generate component makes Lynx components.
  • package.json: start runs ng serve and build runs ng build. Adds @blotch/angular-lynx-build and @lynx-js/types as dev dependencies.
  • .gitignore: adds .dev-logs, where ng serve writes LynxLogger's output.
  • pnpm-workspace.yaml, in a pnpm app: allowBuilds denies the install scripts of Angular's build tools (esbuild, @parcel/watcher, lmdb and msgpackr-extract). pnpm 11 and later fail pnpm add until every dependency's install script is allowed or denied, and these have nothing to do: their binaries come prebuilt. Decisions already there stay. Apps on npm, Yarn or bun, or on pnpm before 10.26, get no file.
  • Tailwind CSS, unless --tailwind=false: the same changes as add-tailwind.

It doesn't write a lynx.config.ts. The builders read everything from angular.json (see @blotch/angular-lynx-build).

OptionTypeDefaultDescription
--projectstringThe current projectThe project to convert
--tailwindbooleantrueAdd Tailwind CSS. You're asked when you don't pass it
--tailwind-version4 | 3The project's own Tailwind version, or 4The Tailwind CSS major version to set up

component

ng generate component pages/dashboard   # or: ng g c pages/dashboard

ng add puts @blotch/angular-lynx first in cli.schematicCollections, so this command runs it. Without that setting, run ng generate @blotch/angular-lynx:component <name>. Other ng generate schematics, such as service and pipe, still come from Angular.

What it changes:

  • Runs Angular's component schematic with your options and angular.json's @schematics/angular:component defaults, so it creates the files you know.
  • The template gets Lynx elements: the <p>dashboard works!</p> placeholder becomes <view><text>dashboard works!</text></view>, in the .html file or inline.
  • The component imports LYNX_ELEMENTS, so its template type-checks in your editor and under ng test. A component declared in an NgModule (--standalone false) is left as Angular made it.
  • The test: if @blotch/angular-lynx-testing-library is in package.json, dashboard.spec.ts is replaced by dashboard.test.ts, which renders the component with render(). Without the library, Angular's spec stays.

It takes all of Angular's component options. Defaults come from angular.json, then Angular.

OptionAliasTypeDescription
namestringThe component name, optionally with a path. Required
--projectstringThe project to add it to
--inline-template-tbooleanPut the template in the .ts file
--inline-style-sbooleanPut the styles in the .ts file
--stylecss | scss | sass | less | noneThe stylesheet type
--skip-testsbooleanDon't create a test file
--flatbooleanDon't create a folder for the files
--typestringAdd a type to the file name, e.g. dashboard.page.ts
--add-type-to-class-namebooleanAlso add the type to the class name
--prefix-pstringThe selector prefix
--selectorstringThe selector
--skip-selectorbooleanDon't give the component a selector
--change-detection-cEager | OnPushThe change detection strategy
--view-encapsulation-vEmulated | None | ShadowDomHow styles are scoped
--display-block-bbooleanAdd :host { display: block; } to the styles
--export-defaultbooleanUse a default export
--ng-htmlbooleanName the template .ng.html
--standalonebooleanMake a standalone component
--module-mstringThe NgModule to declare it in
--exportbooleanExport it from that NgModule
--skip-importbooleanDon't add it to an NgModule

add-tailwind

ng generate @blotch/angular-lynx:add-tailwind

Use it if you skipped Tailwind during ng add. It sets up the Tailwind version the project already depends on, or Tailwind 4. See Tailwind CSS.

What it changes, for Tailwind 4 (as Angular CLI's own Tailwind schematic does):

  • src/styles.css: its contents are replaced with Tailwind's theme and utilities imports, without Preflight, and @blotch/angular-lynx/tailwind.css, Lynx's own utilities and variants. A project styled with styles.scss gets a src/tailwind.css, added to the build's styles, instead.
  • .postcssrc.json: created, or @tailwindcss/postcss added to it (or to postcss.config.json).
  • package.json: adds tailwindcss and @tailwindcss/postcss (4.x) as dev dependencies, keeping the version of a project that has them.
  • It warns about a tailwind.config.ts left from Tailwind 3, which Tailwind 4 doesn't read.

What it changes, for Tailwind 3:

  • tailwind.config.ts: created, or replaced, with @lynx-js/tailwind-preset and content: ['./src/**/*.{html,ts}'].
  • src/styles.css (or styles.scss if it exists): its contents are replaced with @tailwind base; and @tailwind utilities;.
  • package.json: adds tailwindcss (3.x) and @lynx-js/tailwind-preset as dev dependencies.
OptionTypeDefaultDescription
--projectstringThe current projectThe project to change
--tailwind-version4 | 3The project's own Tailwind version, or 4The Tailwind CSS major version to set up

add-testing

ng generate @blotch/angular-lynx:add-testing

Adds the testing library, so tests can render components on Lynx. See Testing.

What it changes:

  • package.json: adds @blotch/angular-lynx-testing-library as a dev dependency, plus vitest and jsdom if they're missing. ng new already adds both. Sets the test script to ng test.
  • angular.json: points test at @blotch/angular-lynx-build:unit-test, if it isn't already. ng add does this for new projects.

There's no Vitest config or setup file to add: ng test loads the library's setup itself. Components you generate from then on get a test that renders them on Lynx.

OptionTypeDefaultDescription
--projectstringThe current projectThe project to change

add-i18n

ng generate @blotch/angular-lynx:add-i18n

Sets up @angular/localize with the device's language. See Internationalization.

What it changes:

  • angular.json: adds an i18n block with sourceLocale: 'en-US' if there's none, and adds @angular/localize/init to the build's polyfills. Sets the extract-i18n target to write JSON, the format loadTranslations() takes, to src/locale, unless the target already sets a format or outputPath. An extract-i18n target of Angular's switches to @blotch/angular-lynx-build:extract-i18n.
  • tsconfig.app.json: adds @angular/localize to compilerOptions.types, so $localize is typed.
  • src/app/app.config.ts: adds provideLocale() as the first provider, unless the file already uses it.
  • package.json: adds @angular/localize as a dev dependency, at the same version range as your @angular/core.
OptionTypeDefaultDescription
--projectstringThe current projectThe project to change

eject

ng generate @blotch/angular-lynx:eject --platform ios

Copies the native projects (the source folders of the iOS and Android apps) that ng build --platform generates into your repo. Eject only when you need a native change that the build options don't cover. See Run on iOS and Android and Eject the native projects.

What it changes:

  • ios/ and android/: created in the project folder. It stops with an error if a folder already exists and isn't empty.
  • ng build --platform then builds those folders as they are.

It's one-way. The app options in angular.json no longer apply to an ejected project, and keeping it up to date with Lynx, Apple's and Google's tools becomes your job. It needs @blotch/angular-lynx-build installed.

OptionTypeDefaultDescription
--projectstringThe current projectThe project to eject
--platformios | android | allallWhich native project to copy

ng update

ng update @blotch/angular-lynx

Updates @blotch/angular-lynx, @blotch/angular-lynx-build, @blotch/angular-lynx-testing-library and the packages they use together, so their versions stay in step.

It also updates your app for changes that need one:

  • 22.2.3:

    • adds .html to the Tailwind content glob that older versions of ng add and add-tailwind wrote (./src/**/*.ts becomes ./src/**/*.{html,ts}), so classes in .html templates get CSS
    • renames accessibility-trait, which Lynx ignores, to accessibility-traits in your templates
    • adds the extract-i18n target that ng add and add-i18n now write, so ng extract-i18n works
    • adds .dev-logs to your .gitignore
  • 22.3.2: imports @blotch/angular-lynx/tailwind.css after Tailwind 4's imports in your stylesheet, so the Lynx utilities and variants, such as linear and ui-open:, get CSS. A Tailwind 3 app is left alone: its preset has them.