Lynx

Installation

Learn how to install and use Crispy in a Lynx project.

Install Dependencies

Install the required common dependencies. Choose the styling library in the next step.

npm install @seed-design/lynx-react @seed-design/lynx-css

Choose a Styling Library

Choose between Vanilla Extract or Tailwind CSS v4 that suits your project. See the Styling Guide for why we recommend static CSS and layout examples.

Styling MethodHow to WriteConfiguration Guide
Vanilla ExtractWrite typed styles and Crispy tokens in .css.ts.Vanilla Extract
Tailwind CSS v4Combine utility classes in className.Tailwind CSS 4

After applying dependencies, build settings, Crispy base.css, and CSS imports in app entry from the chosen guide, proceed to the next step. First check the Rspeedy and Rsbuild requirements in each guide. Vanilla Extract plugin 0.2.0 requires Rsbuild 1, and the Tailwind v4 guide covers Rsbuild 2-based configuration. Existing Tailwind v3 projects can maintain the Tailwind CSS 3 configuration.

Create seed-design.json

npx @seed-design/cli init

Configure seed-design

If @lynx-js/react is installed, the framework is automatically detected as Lynx.

◇  Are you using TypeScript?
│  Yes
│
◇  Which framework are you using?
│  Lynx
│
◇  Enter the path for the seed-design folder. (Default: created at project root.)
│  ./seed-design
│
◇  Collect anonymous usage data for improvements?
│  Yes

Configure seed-design path alias

Must be the same as the path configured in seed-design.json path above.

Add a path alias to the root tsconfig.json so TypeScript can interpret snippet imports.

tsconfig.json
{
  "compilerOptions": {
    // ... your options
    "baseUrl": ".",
    "paths": {
      "seed-design/*": [
        "./seed-design/*"
      ]
    }
  }
}

If you have a separate src/tsconfig.json like the Lynx template and use a composite project, you must also add the generated snippet path to include.

src/tsconfig.json
{
  "include": [
    "./**/*.ts",
    "./**/*.tsx",
    "../seed-design/**/*.ts",
    "../seed-design/**/*.tsx"
  ]
}

Rspeedy/Rspack also needs to know the same alias to interpret seed-design/* imports in runtime build.

lynx.config.ts
import { defineConfig } from "@lynx-js/rspeedy";
import { fileURLToPath } from "node:url";

const seedDesignDir = fileURLToPath(new URL("./seed-design", import.meta.url));

export default defineConfig({
  resolve: {
    alias: {
      "seed-design": seedDesignDir,
    },
  },
});

If using @karrotmarket/lynx-*-icon icon package, you must also configure @seed-design/rsbuild-plugin-lynx-icon to display SVG assets in Lynx. For detailed configuration, see Iconography.

Configure Lynx Feature Flags

This is the basic configuration for Crispy's CSS inheritance, inline variables, Dynamic/Static typography, and fixed elements. CSS Selector and Invalidation use the default values of pluginReactLynx, so you don't need to set them repeatedly. The example below uses options allowed in React plugin 0.18.3 and 0.20.2, config plugin 0.2.2 and 0.2.3.

npm install @lynx-js/config-rsbuild-plugin
lynx.config.ts
import { defineConfig } from "@lynx-js/rspeedy";
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
import { pluginLynxConfig } from "@lynx-js/config-rsbuild-plugin";

export default defineConfig({
  plugins: [
    pluginReactLynx({
      engineVersion: "3.6",
    }),
    // ... existing plugins
    pluginLynxConfig({
      enableCSSInheritance: true,
      enableCSSInlineVariables: true,
      fontScaleEffectiveOnlyOnSp: true,
      enableFixedNew: true,
    }),
  ],
});

Combine options with existing pluginReactLynx calls, and do not register the same plugin twice. engineVersion is the minimum target version of your app. If your existing app requires a higher version, maintain that value. enableTextRefactor is enabled by default in this target version, and you don't need to add enableCSSStrictMode: false as a required Crispy setting.

Check Feature Flags for settings to maintain or omit by engine and build tool version, and optional settings.

Try using a component

npx @seed-design/cli add ui:switch

(Optional) Install lynx-console

lynx-console is a developer tool that lets you check console logs, network, and performance metrics inside your Lynx app.

npm install lynx-console

Initialize it in your app entry and add the component.

src/App.tsx
import {
  initLogMonitor,
  initMainThreadConsole,
  initNetworkMonitor,
  initPerformanceMonitor,
} from "lynx-console/setup";
import LynxConsole from "lynx-console";

initLogMonitor();
initMainThreadConsole();
initNetworkMonitor();
initPerformanceMonitor();

function App() {
  return (
    <view>
      {/* your app */}
      <LynxConsole />
    </view>
  );
}

See lynx-console GitHub for detailed usage.

Table of contents