Lynx

Iconography

Explains how to use the Lynx icon package.

Installation

Monochrome

npm install @karrotmarket/lynx-monochrome-icon

Multicolor

npm install @karrotmarket/lynx-multicolor-icon

Rsbuild Plugin Configuration

You need to configure an Rsbuild plugin that converts Lynx icon SVGs to WebP data URLs.

The @karrotmarket/lynx-*-icon package internally uses SVG assets from the karrotmarket/assets-* package. The plugin below converts the package asset to a WebP data URL module using sharp during build so it can be reliably displayed in Lynx.

npm install -D @seed-design/rsbuild-plugin-lynx-icon
package.json
lynx.config.ts
lynx.config.ts
import { defineConfig } from "@lynx-js/rspeedy";

import { pluginQRCode } from "@lynx-js/qrcode-rsbuild-plugin";
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
import { pluginLynxIcon } from "@seed-design/rsbuild-plugin-lynx-icon";
import { pluginTypeCheck } from "@rsbuild/plugin-type-check";

export default defineConfig({
  plugins: [
    pluginQRCode({
      schema(url) {
        // We use `?fullscreen=true` to open the page in LynxExplorer in full screen mode
        return `${url}?fullscreen=true`;
      },
    }),
    pluginReactLynx(),
    pluginTypeCheck(),
    pluginLynxIcon({
      include:
        /node_modules\/@karrotmarket\/assets-(monochrome|multicolor)\/svg\//,
    }),
  ],
});

Icon Library

You can view the complete icon list on the Icon Library page.

Usage

After installing the icon package and configuring the loader, you can use icons in your project.

import {
  IconArrow2ClockwiseCircularFill,
  IconArrow2ClockwiseCircularLine,
} from "@karrotmarket/lynx-monochrome-icon";
import { IconCamera } from "@karrotmarket/lynx-multicolor-icon";

export function App() {
  return (
    <view>
      <text>Monochrome icons require the color prop.</text>
      <IconArrow2ClockwiseCircularLine size={24} color="gray" />
      <IconArrow2ClockwiseCircularFill size={30} color="gray" />

      <text>Multicolor icons do not have a color prop.</text>
      <IconCamera size={30} />
    </view>
  );
}

Crispy Component Slots

When rendering only icons directly on a regular screen, use the @karrotmarket/lynx-*-icon component as shown in the example above.

When using monochrome icon slots in Crispy components, use the Icon, PrefixIcon, and SuffixIcon wrappers from @seed-design/lynx-react. The wrapper synchronizes the color calculated from the recipe className to Lynx <image> tint-color and passes the slot size to the icon image.

When specifying color, pass it only to the wrapper's color prop. Do not specify color or tint-color on the icon component passed to icon.

import IconChevronDownFill from "@karrotmarket/lynx-monochrome-icon/IconChevronDownFill";
import IconPlusFill from "@karrotmarket/lynx-monochrome-icon/IconPlusFill";
import { ActionButton, Icon, PrefixIcon, SuffixIcon } from "@seed-design/lynx-react";

export function App() {
  return (
    <view>
      <ActionButton>
        <PrefixIcon icon={<IconPlusFill />} />
        Add
        <SuffixIcon icon={<IconChevronDownFill />} />
      </ActionButton>

      <ActionButton layout="iconOnly" accessibility-label="Add">
        <Icon icon={<IconPlusFill />} />
      </ActionButton>
    </view>
  );
}

Table of contents