CLI Guide
The ui-lab command-line tool provides an intuitive way to initialize projects and install components into your existing applications.
Overview
The CLI is published as the ui-lab npm package and can be used either as a global tool or via npx.
Installation:
Requirements:
- Node.js 18 or higher
- npm, yarn, or pnpm
ui-lab init
Initialize a new UI Lab project in your existing application.
Basic Usage:
Usage Modes
Interactive (Default): Guided prompts walk you through framework detection, component directory selection, theme presets, and CSS setup.
Headless: Skip all prompts with defaults or flags:
Options
| Option | Description |
|---|---|
--yes | Skip all interactive prompts |
--preset <theme> | Use specific theme preset |
--framework <fw> | Force framework detection |
--componentDir <path> | Custom component directory |
What init Does
- Detects your framework (Next.js or Vite)
- Creates a component directory
- Generates CSS variables for your theme
- Saves configuration for future commands
Example Output
ui-lab install / ui-lab add
Install specific components into your project. Both install and add work identically.
Basic Usage:
Component Installation
The CLI installs only the components you request:
Features
- Auto-validates component names and suggests corrections
- Resolves dependencies – installs required child components automatically
- Preview mode – preview changes with
--dry-runbefore committing
Options
| Option | Description |
|---|---|
<components> | Space-separated component names |
--yes | Skip confirmation prompts |
--dry-run | Preview without making changes |
Example: With Dependencies & Dry Run
Preview before installing:
Available Components
The CLI recognizes all 27+ components from the UI Lab library:
Layout: button · card · divider · flex · fold · grid · group
Input: checkbox · input · label · radio · select · slider · switch · textarea
Feedback: badge · progress · toast · tooltip
Modal/Overlay: modal · popover · menu · confirmation
Form: form · command-palette
Complex: breadcrumbs · tabs · gallery
Use npx ui-lab list to see all available components (if implemented).
Theme Presets
Choose a preset during init or update later:
To customize colors, edit the generated CSS variables file after initialization.
Project Detection
The CLI automatically detects Next.js (app/pages router) and Vite projects. If detection fails, specify your framework explicitly:
Configuration
The CLI saves your setup in ui-lab.config.json. To update it, run init again:
Troubleshooting
Framework Detection Failed
Problem: CLI doesn't recognize your framework
Solution:
Component Installation Failed
Problem: Component fails to install
Causes & Solutions:
- Component name typo → Check spelling (
ui-lab install buttonnotui-lab install btn) - Dependency missing → Let CLI resolve dependencies automatically
- Directory permissions → Ensure component directory is writable
Theme Preset Not Found
Problem: "Unknown preset" error
Solution:
Network Issues
Problem: "Cannot reach registry" error
Causes & Solutions:
- Check internet connection
- Verify npm registry is accessible
- Try again with exponential backoff
- Check npm configuration:
npm config get registry
Best Practices
1. Initialize First
Always run init before installing components:
2. Use Presets Initially
Start with a preset theme, customize later:
3. Install Components as Needed
Add components incrementally as you need them:
Common Questions
Q: Can I use the CLI without initializing first?
A: Run init first—it sets up configuration for future commands.
Q: How do I change the theme after init?
A: Edit the generated theme CSS file or run init again with a new preset.
Q: Does the CLI modify my existing files?
A: No, it only creates new files. Use --dry-run to preview.
Q: Can I use a custom component directory?
A: Yes: npx ui-lab init --componentDir src/ui
Command Reference
Feedback & Support
Found an issue? Have suggestions for the CLI?
- GitHub Issues: https://github.com/kyza0d/ui-lab.app/issues
- Include CLI version:
npx ui-lab --version - Include framework and Node version
- Describe steps to reproduce