CLI
Use the Shim CLI to initialize and install components.
Overview
Use the Shim CLI to initialize configuration and install components with their dependencies directly into your project.
Usage
Run commands on demand via pnpm dlx (no local install required):
pnpm dlx @kkga/shim init
pnpm dlx @kkga/shim add button dialog formTip: Add a script to your package.json for shorter commands:
{
"scripts": {
"shim": "pnpm dlx @kkga/shim"
}
}pnpm shim init
pnpm shim add button dialog formCommands
shim init
Initialize Shim in your project. Automatically installs required dependencies, creates the configuration file, and installs utility and CSS files.
- Checks if Tailwind CSS is installed (required prerequisite)
- Installs all required dependencies (react-aria-components, tailwind-variants, tailwind-merge, @radix-ui/colors, @phosphor-icons/react)
- Creates a shim.config.json configuration file
- Downloads required utility files (style.ts, theme.tsx) to your utils directory
- Downloads CSS theme file (theme.css) to your styles directory
- Ensures your project is ready for component installation
shim init [options]Option | Description |
|---|---|
--components-path <path> | Destination for components (default: |
--utils-path <path> | Destination for utility files (default: |
--css-path <path> | Destination for CSS files (default: |
-f, --force | Overwrite existing config and installed files. |
shim add
Install one or more components by name. Automatically installs component dependencies.
shim add <components...> [options]Option | Description |
|---|---|
<components...> | One or more component names (e.g. |
-p, --path <path> | Destination for installed components (overrides config |
-f, --overwrite | Overwrite files that already exist. |
Features
- Import transformation: component import paths are rewritten based on your configured destinations.
- Dependency resolution: component dependencies are installed automatically.
- Utility management:
style.ts,theme.tsx, andtheme.cssare created and kept in your chosen directories.
Examples
pnpm dlx @kkga/shim initpnpm dlx @kkga/shim init \
--components-path src/ui \
--utils-path src/lib \
--css-path src/stylespnpm dlx @kkga/shim add button dialog formpnpm dlx @kkga/shim add button --path src/features/uipnpm dlx @kkga/shim add dialog --overwrite# package.json: { "scripts": { "shim": "pnpm dlx @kkga/shim" } }
pnpm shim add buttonConfiguration File
Running shim init creates a configuration file in your project root:
{
"componentsPath": "components",
"utilsPath": "utils",
"cssPath": "styles"
}Option | Description |
|---|---|
componentsPath | Default destination for installed components. |
utilsPath | Destination for downloaded utility files. |
cssPath | Destination for downloaded CSS files. |
Troubleshooting
Tailwind CSS is not installed
shim init requires Tailwind CSS to be installed. If you see this error,
install and configure Tailwind first:
pnpm add -D tailwindcss postcss autoprefixer
pnpm tailwindcss init -pSee the Tailwind installation guide for framework-specific setup.
Component not found
If you get a "component not found" error, check your spelling. To see available components, visit the components section or check the registry.
Files already exist
Use --overwrite (for add) or --force (for init) to replace existing
files:
pnpm dlx @kkga/shim add button --overwrite
pnpm dlx @kkga/shim init --forceInvalid path error
Paths should be relative to your project root (where package.json is):
# ✓ Good
pnpm dlx @kkga/shim init --components-path src/components
# ✗ Bad (absolute filesystem path)
pnpm dlx @kkga/shim init --components-path /Users/name/project/src/components