> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Schematics

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

| Schematic                       | Command                                  | What it does                                       |
| ------------------------------- | ---------------------------------------- | -------------------------------------------------- |
| [`ng-add`](#ng-add)             | `ng add @blotch/angular-lynx`            | Turns an `ng new` project into a Lynx app          |
| [`component`](#component)       | `ng generate component <name>`           | Generates a component with a Lynx template         |
| [`add-tailwind`](#add-tailwind) | `ng g @blotch/angular-lynx:add-tailwind` | Adds Tailwind CSS                                  |
| [`add-testing`](#add-testing)   | `ng g @blotch/angular-lynx:add-testing`  | Adds the AngularLynx testing library               |
| [`add-i18n`](#add-i18n)         | `ng g @blotch/angular-lynx:add-i18n`     | Adds `@angular/localize` and `provideLocale()`     |
| [`eject`](#eject)               | `ng g @blotch/angular-lynx:eject`        | Copies 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`

```bash
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`](/guide/debugging.md#stream-logs-to-your-computer)'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`](#add-tailwind).

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

| Option               | Type       | Default                                    | Description                                           |
| -------------------- | ---------- | ------------------------------------------ | ----------------------------------------------------- |
| `--project`          | `string`   | The current project                        | The project to convert                                |
| `--tailwind`         | `boolean`  | `true`                                     | Add Tailwind CSS. You're asked when you don't pass it |
| `--tailwind-version` | `4` \| `3` | The project's own Tailwind version, or `4` | The Tailwind CSS major version to set up              |

## `component`

```bash
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()`](/api/testing-library/index.md). Without the library, Angular's spec stays.

It takes all of [Angular's component options](https://angular.dev/cli/generate/component). Defaults come from `angular.json`, then Angular.

| Option                     | Alias | Type                                          | Description                                           |
| -------------------------- | ----- | --------------------------------------------- | ----------------------------------------------------- |
| `name`                     |       | `string`                                      | The component name, optionally with a path. Required  |
| `--project`                |       | `string`                                      | The project to add it to                              |
| `--inline-template`        | `-t`  | `boolean`                                     | Put the template in the `.ts` file                    |
| `--inline-style`           | `-s`  | `boolean`                                     | Put the styles in the `.ts` file                      |
| `--style`                  |       | `css` \| `scss` \| `sass` \| `less` \| `none` | The stylesheet type                                   |
| `--skip-tests`             |       | `boolean`                                     | Don't create a test file                              |
| `--flat`                   |       | `boolean`                                     | Don't create a folder for the files                   |
| `--type`                   |       | `string`                                      | Add a type to the file name, e.g. `dashboard.page.ts` |
| `--add-type-to-class-name` |       | `boolean`                                     | Also add the type to the class name                   |
| `--prefix`                 | `-p`  | `string`                                      | The selector prefix                                   |
| `--selector`               |       | `string`                                      | The selector                                          |
| `--skip-selector`          |       | `boolean`                                     | Don't give the component a selector                   |
| `--change-detection`       | `-c`  | `Eager` \| `OnPush`                           | The change detection strategy                         |
| `--view-encapsulation`     | `-v`  | `Emulated` \| `None` \| `ShadowDom`           | How styles are scoped                                 |
| `--display-block`          | `-b`  | `boolean`                                     | Add `:host { display: block; }` to the styles         |
| `--export-default`         |       | `boolean`                                     | Use a default export                                  |
| `--ng-html`                |       | `boolean`                                     | Name the template `.ng.html`                          |
| `--standalone`             |       | `boolean`                                     | Make a standalone component                           |
| `--module`                 | `-m`  | `string`                                      | The NgModule to declare it in                         |
| `--export`                 |       | `boolean`                                     | Export it from that NgModule                          |
| `--skip-import`            |       | `boolean`                                     | Don't add it to an NgModule                           |

## `add-tailwind`

```bash
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](/guide/tailwindcss.md).

**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](/guide/tailwindcss.md#lynx-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.

| Option               | Type       | Default                                    | Description                              |
| -------------------- | ---------- | ------------------------------------------ | ---------------------------------------- |
| `--project`          | `string`   | The current project                        | The project to change                    |
| `--tailwind-version` | `4` \| `3` | The project's own Tailwind version, or `4` | The Tailwind CSS major version to set up |

## `add-testing`

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

Adds the [testing library](/api/testing-library/index.md), so tests can render components on Lynx. See [Testing](/guide/testing/index.md).

**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.

| Option      | Type     | Default             | Description           |
| ----------- | -------- | ------------------- | --------------------- |
| `--project` | `string` | The current project | The project to change |

## `add-i18n`

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

Sets up `@angular/localize` with the device's language. See [Internationalization](/guide/i18n/index.md).

**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`.

| Option      | Type     | Default             | Description           |
| ----------- | -------- | ------------------- | --------------------- |
| `--project` | `string` | The current project | The project to change |

## `eject`

```bash
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](/api/build/index.md#native-app-options) don't cover. See [Run on iOS and Android](/guide/native-apps/index.md) and [Eject the native projects](/guide/native-apps/eject.md).

**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.

| Option       | Type                        | Default             | Description                  |
| ------------ | --------------------------- | ------------------- | ---------------------------- |
| `--project`  | `string`                    | The current project | The project to eject         |
| `--platform` | `ios` \| `android` \| `all` | `all`               | Which native project to copy |

## `ng update`

```bash
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](/guide/tailwindcss.md#lynx-utilities-and-variants), such as `linear` and `ui-open:`, get CSS. A Tailwind 3 app is left alone: its preset has them.

## Related

- [Quick Start](/guide/quick-start.md)
- [`@blotch/angular-lynx-build`](/api/build/index.md)
- [Testing](/guide/testing/index.md)
