|
| 1 | +# @formkit/theme-regenesis |
| 2 | + |
| 3 | +The official reference theme for FormKit. A fully-styled, production-ready theme demonstrating best practices for FormKit theming with Tailwind CSS. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +``` |
| 8 | +src/ |
| 9 | +├── theme.ts # Main theme definition (createTheme call) |
| 10 | +├── globals.ts # Global styles for all inputs |
| 11 | +├── main.ts # Dev server entry point |
| 12 | +├── App.vue # Kitchen sink demo |
| 13 | +├── style.css # Dev UI variables |
| 14 | +├── families/ # Shared style groups |
| 15 | +│ ├── button.ts # button, submit |
| 16 | +│ ├── box.ts # checkbox, radio |
| 17 | +│ ├── text.ts # text, email, number, date... |
| 18 | +│ └── dropdown.ts # autocomplete, dropdown, taglist |
| 19 | +└── inputs/ # Input-specific styles |
| 20 | + ├── [21 core inputs] |
| 21 | + ├── pro/ # 12 premium inputs |
| 22 | + └── addon/ # barcode, multi-step |
| 23 | +``` |
| 24 | + |
| 25 | +## Theme Variables |
| 26 | + |
| 27 | +| Variable | Editor | Default | Description | |
| 28 | +|----------|--------|---------|-------------| |
| 29 | +| `radius` | radius | rounded-md | Border radius | |
| 30 | +| `accentColor` | color | blue | Primary accent | |
| 31 | +| `colorTemperature` | color | neutral | Gray palette | |
| 32 | +| `spacing` | spacing | 2 | Base spacing unit | |
| 33 | +| `scale` | fontSize | base | Text scale | |
| 34 | +| `inputShadow` | shadow | shadow-sm | Input shadows | |
| 35 | +| `baseColorShade` | buttons | 600 | Color intensity | |
| 36 | +| `borderShadeLightMode` | buttons | 400 | Light borders | |
| 37 | +| `borderShadeDarkMode` | buttons | 500 | Dark borders | |
| 38 | + |
| 39 | +Advanced variables: `inputMaxWidth`, `tagRadius`, `swatchRadius` |
| 40 | + |
| 41 | +## Style Inheritance |
| 42 | + |
| 43 | +``` |
| 44 | +__globals (globals.ts) |
| 45 | + ↓ base styles for all inputs |
| 46 | +family:text/box/button/dropdown |
| 47 | + ↓ shared styles for input groups |
| 48 | +input-specific (inputs/*.ts) |
| 49 | + ↓ final overrides |
| 50 | +``` |
| 51 | + |
| 52 | +## Input Coverage |
| 53 | + |
| 54 | +**Core (21):** button, checkbox, color, date, datetime-local, email, file, form, month, number, password, radio, range, search, select, submit, tel, text, textarea, time, url, week |
| 55 | + |
| 56 | +**Pro (12):** autocomplete, colorpicker, datepicker, dropdown, mask, rating, repeater, slider, taglist, toggle, togglebuttons, transferlist |
| 57 | + |
| 58 | +**Addon (2):** barcode, multi-step |
| 59 | + |
| 60 | +## Development |
| 61 | + |
| 62 | +```bash |
| 63 | +pnpm dev # Vite dev server with theme editor |
| 64 | +pnpm build # tsup → dist/theme.{js,cjs,d.ts} |
| 65 | +pnpm test # vitest |
| 66 | +``` |
| 67 | + |
| 68 | +Dev server uses: |
| 69 | +- `@formkit/theme-editor` for live variable editing |
| 70 | +- `FormKitKitchenSink` for all-inputs demo |
| 71 | +- Tailwind CDN for instant class updates |
| 72 | + |
| 73 | +## Key Patterns |
| 74 | + |
| 75 | +### Variable usage in classes |
| 76 | + |
| 77 | +```typescript |
| 78 | +// Simple substitution |
| 79 | +input: 'p-$spacing rounded-$radius' |
| 80 | + |
| 81 | +// With scale shifting |
| 82 | +outer: 'mb-$spacing(-2)' // -2 from current value |
| 83 | + |
| 84 | +// Color with shade |
| 85 | +border: 'border-$accentColor-$baseColorShade' |
| 86 | + |
| 87 | +// Dark mode variant |
| 88 | +text: 'text-$colorTemperature-700 dark:text-$colorTemperature-300' |
| 89 | +``` |
| 90 | + |
| 91 | +### Family inheritance |
| 92 | + |
| 93 | +Most inputs export empty objects and inherit from families: |
| 94 | +```typescript |
| 95 | +// text.ts - inherits everything from family:text |
| 96 | +export default {} |
| 97 | +``` |
| 98 | + |
| 99 | +Override specific sections as needed: |
| 100 | +```typescript |
| 101 | +// checkbox.ts - only override decorator |
| 102 | +export default { |
| 103 | + decorator: '$radius(0,rounded-none,rounded-sm)', |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +## Interconnections |
| 108 | + |
| 109 | +``` |
| 110 | +@formkit/theme-creator |
| 111 | + ↓ provides createTheme(), rootClasses() |
| 112 | +theme-regenesis (this package) |
| 113 | + ↓ exports theme function |
| 114 | +├── themes.formkit.com (displays/edits theme) |
| 115 | +├── theme-editor (previews with this theme) |
| 116 | +└── User projects (import and use) |
| 117 | +``` |
| 118 | + |
| 119 | +## Build Output |
| 120 | + |
| 121 | +- `dist/theme.js` - ESM |
| 122 | +- `dist/theme.cjs` - CommonJS |
| 123 | +- `dist/theme.d.ts` - TypeScript declarations |
| 124 | + |
| 125 | +External dependency: `@formkit/theme-creator` (not bundled) |
| 126 | + |
| 127 | +## Common Tasks |
| 128 | + |
| 129 | +### Adding styles for a new input |
| 130 | + |
| 131 | +1. Create `src/inputs/[name].ts` or `src/inputs/pro/[name].ts` |
| 132 | +2. Export section classes (or empty object for family inheritance) |
| 133 | +3. Import and add to `inputs` object in `theme.ts` |
| 134 | +4. Add to `meta.supportedInputs` array |
| 135 | + |
| 136 | +### Modifying a family style |
| 137 | + |
| 138 | +Edit the appropriate file in `src/families/`: |
| 139 | +- Changes apply to all inputs in that family |
| 140 | +- Individual inputs can still override |
| 141 | + |
| 142 | +### Testing style changes |
| 143 | + |
| 144 | +1. Run `pnpm dev` |
| 145 | +2. Theme editor appears in corner |
| 146 | +3. Adjust variables to test different configurations |
| 147 | +4. All inputs visible in FormKitKitchenSink |
0 commit comments