Adding Components to a Preset
Once you have created a preset, you can start adding custom component implementations to it. KatluxToolkit uses a dynamic resolution system that searches for components within your `presets/{presetName}/components/` folder.
1. Preset Structure Checklist
Before adding components, ensure your preset follows the standard structure:
2. How to Add a Component
To add a component (e.g., `KButton`) to your custom preset, simply create its folder and file implementation inside the `components/` sub-directory:
3. The Fallback Mechanism
One of the most powerful features of KatluxToolkit is the fallback mechanism. You don't need to implement every single component for every preset.
Important: If a component is missing in your active preset, KatluxToolkit will automatically fall back to the default component implementation.
This allows you to:
- Incrementally build your preset.
- Only override the components that need a different visual style.
- Ensure your application always works even if a preset is incomplete.
4. Component Resolution Example
When you use a global component like `KButton` while the active preset is set to `modern`:
- The system looks in: `presets/modern/components/KButton/KButton.vue`.
- If found, it renders that component.
- If NOT found, it falls back to the default toolkit implementation.
5. Defining Props and Models
When creating a component in your preset, you must define the `props` and `models` it receives. These are passed down from the global component.
Tip: Use Vue 3.5's `defineModel` for two-way bindings (like selection state) and `defineProps` for data passed down from the logic layer.
Advanced Example: Modern Datatable
For complex components like `KDatatable`, you often need to handle selection states and large data objects.
In `presets/modern/components/KDatatable/KDatatable.vue`:
Simplest Example: Modern Button
In `presets/modern/components/KButton/KButton.vue`: