Setting Up the UI Kit Generator
What you'll learn
- Adding
ui-kitandtheme-variantcommands to your monorepo toolkit - Scaffolding components from the CLI without manual prompts
- Batch-generating multiple components
- Managing theme variants from the command line
Prerequisites
- An existing Archipelago monorepo (see Monorepo Scaffolding)
- Monorepo Toolkit already generated (see Monorepo Toolkit Setup)
- UI Kit already generated (see UI Kit Setup)
Step 1: Generate the UI Kit Generator
bash
archipelago generate ui_kit_generatorYou will be prompted for:
- appName —
MyApp(must match your monorepo app name) - isForMonorepo —
true
Or use a config file:
json
{
"appName": "MyApp",
"isForMonorepo": true
}bash
archipelago generate ui_kit_generator --config uikit_gen_config.jsonStep 2: Understand the Generated Structure
The generator adds commands to your existing monorepo toolkit:
devtools/
├── monorepo_toolkit/
│ └── lib/src/commands/
│ ├── ui_kit_command.dart # Scaffold components
│ └── theme_variant_command.dart # Generate theme variants
└── scripts/
└── ui_kit_generator/
├── lib/src/
│ ├── component_scaffolder.dart # Component generation logic
│ └── theme_scaffolder.dart # Theme generation logic
└── pubspec.yamlStep 3: Scaffold a Component via CLI
Instead of running archipelago generate ui_kit_component with interactive prompts, use the toolkit command:
bash
monorepo_toolkit ui-kit create button \
--atomic-type atom \
--widget-type stateful \
--prefix App \
--variants \
--sizes \
--typesThis is equivalent to generating a component brick but faster for batch workflows.
Step 4: Generate a Theme Variant
bash
monorepo_toolkit theme-variant create high_contrast \
--prefix App \
--base-theme light \
--color-overrides \
--typography-overridesStep 5: Batch Scaffolding
Create a manifest file for generating multiple components at once:
yaml
# ui_components.yaml
components:
- name: button
atomic_type: atom
widget_type: stateful
variants: true
sizes: true
types: true
- name: card
atomic_type: molecule
widget_type: stateless
variants: true
sizes: false
types: false
- name: dialog
atomic_type: molecule
widget_type: stateful
variants: false
sizes: true
types: falsebash
monorepo_toolkit ui-kit batch --config ui_components.yamlCommon Customizations
| Customization | Where to Change |
|---|---|
| Default prefix | Configure in toolkit settings |
| Component templates | scripts/ui_kit_generator/lib/src/ |
| Custom atomic levels | Extend component_scaffolder.dart |
| Post-generation hooks | Add barrel export updates |
Next Steps
- Create a UI component to understand the generated output
- Add theme variants using the generated CLI commands