Prerequisites#
Before installing Sugarcoat, ensure you have:
- Node.js 18.0 or higher
- npm, pnpm, or yarn package manager
- An existing JavaScript/TypeScript project with
package.json
Installing the CLI#
You can use the CLI directly with npx without installing it globally:
Or install it globally for convenience:
Initializing a Project#
Run the init command in your project root:
The interactive setup will guide you through:
- Brand Color - Choose your primary brand color (e.g., iris, blue, teal)
- Accent Color - Choose a secondary accent color
- Gray Scale - Choose your neutral gray scale (e.g., slate, gray, mauve)
Non-Interactive Setup#
Skip prompts and use defaults with the -y flag:
Force overwrite existing configuration:
Install Dependencies#
After initialization, install the required dependencies:
Generate CSS Artifacts#
Generate the CSS artifacts from your configuration:
This creates the following in .sugarcoat/generated/:
- CSS utility functions (
css,cx,cva) - Design tokens
- Component recipes
- Layout patterns
styles.csswith extracted styles
Configure Your Project#
1. Import Styles#
Import the generated CSS in your app's entry point:
2. Update TypeScript Paths#
Add the path alias to your tsconfig.json:
3. Configure PostCSS#
The init command creates a postcss.config.js. Verify it includes:
Verify Your Setup#
Run the doctor command to verify everything is configured correctly:
This checks:
- Configuration files exist
- Dependencies are installed
- TypeScript paths are configured
- PostCSS is set up
- Generated artifacts exist
Development Workflow#
For development, run codegen in watch mode alongside your dev server:
The dev command watches for file changes and regenerates CSS automatically.
Next Steps#
- Add components from the registry
- Configure your theme in
sugarcoat.config.ts - Browse available components