Component Generator
Always use the generator to create new components. This applies to both humans and AI assistants.
The generator is the single source of truth for wiring up a new component. It automatically:
- Creates
src/components/<name>/<name>.tswith base Lit component and design tokens - Creates
src/components/<name>/README.mdwith API documentation template - Creates
docs/components/<name>.mdwith a VitePress docs page - Updates
src/index.tswith the barrel export - Updates the VitePress sidebar in
docs/.vitepress/config.ts
Usage
bash
npm run generate <component-name>The name will be automatically prefixed with tx- if not already:
bash
npm run generate tooltip # creates tx-tooltip
npm run generate tx-tooltip # same resultExample
bash
npm run generate tx-dialogOutput:
✓ Created src/components/tx-dialog/tx-dialog.ts
✓ Created src/components/tx-dialog/README.md
✓ Created docs/components/tx-dialog.md
✓ Updated src/index.ts with TxDialog export
✓ Updated VitePress sidebar (if config exists)Then edit src/components/tx-dialog/tx-dialog.ts to build your component.
Why Use the Generator?
Manually creating component files risks:
- Forgetting to add the barrel export in
src/index.ts - Missing the VitePress docs page
- Inconsistent file structure or naming
- Missing the sidebar entry
The generator eliminates all of these. Do not skip it.
For AI Assistants
If you are an AI working on this codebase, always run npm run generate <name> before implementing a new component. Do not manually create component files, as you will miss wiring steps.