React

Guide

Guide to the tasks needed to migrate from Sprout to Crispy.

Migration Overview

To migrate from Sprout to Crispy, proceed in the order shown below.

  1. Analyze previous version usage
  2. Install Crispy
  3. Foundation migration (batch application recommended)
  4. Component migration (screen-by-screen application recommended and incremental application possible)

Foundation migration is applied as a batch replacement across the entire project. Components can be applied afterward on a screen-by-screen basis or incrementally by component.

Installing Crispy

Perform the foundational work needed to use Crispy first. After completing the work below, Crispy usage is available.

Installing Dependencies

Install the required dependencies.

npm install @seed-design/react @seed-design/css
  • @seed-design/react includes the complete React component library.
    • It replaces the existing sprout packages.
    • Use the existing packages until component migration is complete.
  • @seed-design/css includes everything related to styles (vars, theming, recipe, css, etc.).
    • It replaces the existing @seed-design/stylesheet library.
    • It replaces the existing @seed-design/design-token library.
    • Use the existing packages until foundation migration is complete.

CSS import

It is interoperable with the global.css of the Sprout @seed-design/stylesheet package.

If you are using a bundler plugin (webpack, vite, rsbuild), use base.css instead of all.css.

index.tsx
import "@seed-design/css/all.css"; 

For how to use the Crispy stylesheet, refer to the Installation CSS import guide.

Applying Theme

Changes

The data-attribute used in the previous Sprout has changed.

<html data-seed data-seed-scale-color="light" />
<html data-seed data-seed-color-mode="system" data-seed-user-color-scheme="light" />
  • data-seed: Apply Crispy global theme (kept as-is in Crispy)
  • data-seed-color-mode: Force apply Crispy theme
    • You can choose one of light-only, dark-only, or system.
  • data-seed-user-color-scheme: User device settings
    • Has a value of either light or dark.
    • If you have code using the data-seed-scale-color attribute in Sprout, change it to the data-seed-user-color-scheme attribute.

Theming

Check the detailed explanation and usage methods for theme attributes.

While you can apply these attributes directly, the plugin application method is recommended. If you are using an unsupported bundler, apply it using the script application method directly.

Plugin Application

For projects using bundlers such as Vite, Rsbuild, and Webpack, you can apply Theming immediately by adding a plugin.

When using Vite

npm install @seed-design/vite-plugin

When using Rsbuild

npm install @seed-design/rsbuild-plugin

When using Webpack

npm install @seed-design/webpack-plugin

Script Application

Generate a script using the generateThemingScript function provided by the @seed-design/css/theming package.

index.tsx
import { generateThemingScript } from "@seed-design/css/theming";

Apply the generated script directly.

<script>
  {generateThemingScript({ mode: "system | light-only | dark-only" })}
</script>

Alternatively, you can write the script directly.

Foundation Migration

Foundation migration requires work on two main areas: Color and Typography.

Analyzing Usage

First, you need to analyze how the @seed-design/design-token package is used in the current project.

  • Usage of vars from the @seed-design/design-token package
  • Components that extend and use vars from the @seed-design/design-token package
  • Code usage of the components mentioned above
  • Usage of the @seed-design/stylesheet package
  • Usage of CSS Variables starting with the --seed- prefix
  • Usage combining the CSS library in use with the @seed-design/design-token package

You can also analyze the usage in your current project using the prompt below.

prompt
I need to migrate Crispy design tokens to new tokens.
Write a report on which parts of the code need to be changed.

1. Usage of vars variables from the `@seed-design/design-token` package
2. Components that extend and use vars variables from the `@seed-design/design-token` package
3. Code usage of components from item 2
4. Usage of the `@seed-design/stylesheet` package
5. Usage of CSS Variables starting with the `--seed-` prefix
6. Usage combining the CSS library in use with the `@seed-design/design-token` package

Beyond the cases above, also identify and tell me what additional parts need to be migrated.

Migration Strategy

  • If you are using multiple packages, migrate the common packages first.
  • If using preprocessing, it is better to first migrate the preprocessing code itself to Crispy and then migrate the remaining code using Codemod.
  • While Color and Typography can be done separately, it is more efficient to migrate Color and Typography simultaneously and then perform QA once.

Typography Preset

Many projects create and use utility functions based on existing typography tokens.

In such cases, refer to the code below, perform preprocessing, and then change the code accordingly.

typography.ts
import type { TextVariant } from '@seed-design/css/recipes/text';

import { vars as typographyVars } from '@seed-design/css/vars/component/typography';

/**
 * @see https://crispy.carrot-soft.tech/foundations/typography
 * @example
 * typography.t1Bold
 * typography.t2Regular
 * typography.t3Bold
 * typography.t4Regular
 * typography.t5Bold
 * typography.t6Bold
 * typography.t7Bold
 * typography.screenTitle
 * ...
 */
export const typography = Object.entries(typographyVars).reduce(
  (acc, [key, value]) => {
    const withoutPrefix = key.replace('textStyle', '');
    const firstChar = withoutPrefix.charAt(0).toLowerCase();
    const restOfString = withoutPrefix.slice(1);
    const name = (firstChar + restOfString) as TextVariant['textStyle'];
    acc[name] = value.enabled.root;
    return acc;
  },
  {} as Record<
    TextVariant['textStyle'],
    {
      fontSize: string;
      fontWeight: string;
      lineHeight: string;
    }
  >,
);

Codemod

Migration is basically done using Codemod.

npx @seed-design/codemod@latest <transform> <target_path> <options>
  • Codemod provides separate color and typography transforms by default.
  • Currently, it provides transforms for CSS-in-JS libraries such as Tailwind CSS, Stitches, Emotion, and Vanilla Extract CSS.
  • Custom transforms provided by each team are provided with the replace-custom- prefix.
  • You can review examples of custom transform changes and use them if your project has the same situation.
  • Additionally, you can create a custom transform if a specific library's transform is needed. (Contact the Design Core team)

Tailwind CSS

Stitches CSS

Emotion, Vanilla Extract CSS, (CSS-in-JS)

  • CSS-in-JS libraries such as Emotion and Vanilla Extract CSS usually use @seed-design/design-token.
  • You can migrate en masse using the replace-seed-design-token-vars transform.
  • This transform changes both color and typography simultaneously.

Native CSS

Codemod Usage Precautions

Since Codemod changes multiple files, care is required.

  • It is recommended to use a separate branch to track changes and manage history.
  • It is recommended to divide commits by transform.
  • Run lint and test after running Codemod.

Codemod Log File

You can generate log files that help with debugging when running Codemod.

  • Add the --log option.
  • Log files are created in the .report folder at the Codemod execution path.
  • Log files help track changes and manage history.
{transform_name}-debug.log
{transform_name}-issues.log
{transform_name}-success.log

debug.log

  • Records debugging information.
  • Records the file paths and times of attempted changes.
debug.log
2025-03-28 19:17:36 [DEBUG]: Starting transformation of /Project/src/component1.tsx
2025-03-28 19:17:36 [DEBUG]: Starting transformation of /Project/src/component2.tsx
2025-03-28 19:17:36 [DEBUG]: Starting transformation of /Project/src/component3.tsx
2025-03-28 19:17:36 [DEBUG]: Starting transformation of /Project/src/component4.tsx

issues.log

  • Records changes that need review.
  • Records the problematic file path and line number.
  • Records the reason for the problem.
  • Except for cases without mapping, changes have already been made.
issues.log
2025-03-28 18:46:55 [WARN]: /Project/src/component1.tsx (line: 171)
 ↳ reason: $gray900-static color changing from static to palette, need to understand purpose
2025-03-28 18:46:55 [WARN]: /Project/src/component2.tsx (line: 194)
 ↳ reason: $gray900-static color changing from static to palette, need to understand purpose
2025-03-28 18:46:55 [WARN]: /Project/src/component3.tsx (line: 147)
 ↳ reason: $gray900-static color changing from static to palette, need to understand purpose
2025-03-28 18:46:56 [WARN]: /Project/src/component4.tsx (line: 242)
 ↳ reason: $gray900-static color changing from static to palette, need to understand purpose

Common issues are organized at the bottom in How do I resolve issues in the issues.log file?.

success.log

  • Helps track changes.
  • Records the changed file paths and line numbers.
  • Records the changed tokens.
  • For transforms that change CSS files, tokens are not recorded individually.
  • For cases like tailwind, the changed className is recorded.
success.log
2025-03-28 18:46:54 /Project/src/hooks/hook1.tsx (line: 149): $gray900 → $palette-gray-1000 (line 149)
2025-03-28 18:46:54 /Project/src/hooks/hook2.tsx (line: 155): $gray700 → $palette-gray-800 (line 155)
2025-03-28 18:46:54 /Project/src/components/component1.tsx (line: 54): $divider1-semantic → $stroke-neutral-muted (line 54)
2025-03-28 18:46:54 /Project/src/components/component2.tsx (line: 60): $paperDefault-semantic → $bg-layer-default (line 60)

Sprout-Crispy Compatibility

After completing the Color and Typography migration, there may be compatibility issues with existing Sprout components.

We provide a Compatibility version of Sprout with all Sprout tokens replaced with Crispy tokens inside. Foundation migration is considered complete once you progress to this point.

On the Sprout Compatibility version page, replace all components with the latest version that has the -v3-compat tag. (All components provide the same version.)

Note: If using a very old version, there may be breaking changes within the components.

Once you have installed the Sprout-Crispy Compatibility version, foundation migration is considered complete. In theory, you can now remove the @seed-design/design-token and @seed-design/stylesheet packages. Also, you can incrementally use Crispy components.

Removing Compat Script

<script src="https://assets.krrt.io/daangn/seed-design-critical-script/latest/lib/index.js"></script>

The script that was previously added to change the Sprout background color to Crispy for app version 25.10.0 and later can be removed after migration is complete.

Component Migration

TBD

Frequently Asked Questions

How do I resolve issues in the issues.log file?

Token mapping fails (Color, Typography)

  • This occurs when using tokens not supported by Crispy. (Mainly alpha color tokens or very small or large typography tokens.)
  • To check token mapping, refer to the explanation.
  • In this case, consult with the designer and manually map to another appropriate token.
  • If you have difficulty with the decision, contact the Design Core team.

Alpha token disappeared (Color)

  • In most cases, tokens with alpha are no longer used.
  • Apply the alpha channel directly in CSS. (Use the opacity property or apply directly in rgba format)

Static token changed to palette (Color)

  • In Crispy, static color tokens typically only support white and black.
  • Other colors (yellow, green, blue, red, gray) etc. have been changed to palette tokens.
  • Verification is needed because colors may vary depending on dark mode and light mode.
  • The background might change while text color doesn't, or vice versa.
  • In most cases, it was changed to palette tokens because static tokens are not needed.
  • In this case, consult with the designer and manually map the existing static token to another appropriate palette token.

Token mapped to two choices (Color)

  • In some color token cases, there are two alternative tokens. (e.g., primary -> bg.brand-solid, fg.brand)
  • fg is a color used for foreground elements of the UI such as text and icons. (color, fill, etc.)
  • bg is a color used for the entire screen or UI background. (backgroundColor, etc.)
  • Codemod may have difficulty determining which token needs to be changed.
  • In this case, manually map to an appropriate token.

Changed to alternate token (Typography)

  • Basically, Mapping supports 1:1 mapping.
  • However, if the token is deprecated in Crispy, it can be mapped to an alternative token.
  • In such cases, the font size or line height may have changed.
  • In this case, you need to verify the UI directly.

Where can I check foundation token mapping?

You can check token mapping at Migration Reference.

Known Issues

When using Vanilla Extract CSS + Vite + Crispy

  • Build may fail when using @vanilla-extract/vite-plugin and @seed-design/vite-plugin together.
  • Upgrade @vanilla-extract/vite-plugin to version 5 or later.

Table of contents