Widget System Overview
Complete widget system overview covering 3-pillar architecture, management, and simplified navigation.
Last updated: 2/3/2026
Widget System Overview
Welcome to the comprehensive SveltyCMS widget system documentation. The widget system is built on a modern 3-Pillar Architecture providing type safety, performance optimization, and developer-friendly patterns.
π Documentation Map
| Guide | Description |
|---|---|
| Architecture | Deep dive into the Factory Pattern, Runtime Discovery, and Data Flow. |
| Development Guide | Practical tutorial for building, testing, and translating widgets. |
| Marketplace | Discovering, installing, and publishing widgets to the ecosystem. |
| Select Widget | Standard dropdown selection widget. |
| Repeater Widget | Documentation for the core Repeater widget. |
| Price Widget | Documentation for the custom Price widget. |
ποΈ Core Concepts
The 3-Pillar Architecture
Every widget in SveltyCMS follows a strict separation of concerns to ensure maintainability and performance:
graph TB
subgraph "Widget Structure"
D[π Definition
index.ts] I[βοΈ Input Component
input.svelte] V[ποΈ Display Component
display.svelte] end D --> |"Configuration & Validation"| I D --> |"Schema & Defaults"| V I --> |"Interactive Editing"| U[User Interface] V --> |"Read-only Display"| L[Lists & Views] style D fill:#e1f5fe style I fill:#f3e5f5 style V fill:#e8f5e8
index.ts] I[βοΈ Input Component
input.svelte] V[ποΈ Display Component
display.svelte] end D --> |"Configuration & Validation"| I D --> |"Schema & Defaults"| V I --> |"Interactive Editing"| U[User Interface] V --> |"Read-only Display"| L[Lists & Views] style D fill:#e1f5fe style I fill:#f3e5f5 style V fill:#e8f5e8
- Definition (
index.ts): The immutable blueprint. Defines the schema, validation rules using Valibot, and default configuration. - Input (
input.svelte): The interactive editor used in the Content Manager. Handles user input, validation feedback, and two-way binding. - Display (
display.svelte): The lightweight read-only view. Optimized for lists, tables, and previews where interaction isnβt needed.
Widget Categories
- Core Widgets: Bundled with the system (e.g., Input, RichText, MediaUpload). Always available and cannot be disabled.
- Custom Widgets: Optional extensions (e.g., SEO, ColorPicker). Can be enabled/disabled per tenant.
- Marketplace Widgets: Downloadable widgets installed at runtime without server restarts.
π Quick Start
Using Existing Widgets in Collections
Defined in your collection schema fields array:
import { widgets } from '@widgets';
export default {
fields: [
widgets.Input({
label: 'Title',
required: true,
translated: true // Enable multilingual support
}),
widgets.RichText({
label: 'Content',
toolbar: 'full'
}),
widgets.MediaUpload({
label: 'Featured Image',
accept: 'image/*'
})
]
};
Creating a Simple Custom Widget
Use the createWidget factory:
// src/widgets/custom/rating/index.ts
import { createWidget } from '@widgets/widgetFactory';
import * as v from 'valibot';
export default createWidget({
Name: 'Rating',
Icon: 'mdi:star',
Description: '5-star rating widget',
inputComponentPath: '/src/widgets/custom/rating/input.svelte',
displayComponentPath: '/src/widgets/custom/rating/display.svelte',
// Validation
validationSchema: v.number([v.minValue(1), v.maxValue(5)]),
defaults: {
value: 0
}
});
π οΈ System Features
Key Capabilities
- β Type Safety: Full TypeScript support throughout.
- π Runtime Ecosystem: Widgets can be installed and loaded without rebuilding the application.
- π’ Multi-Tenant: Different widget configurations per tenant.
- ποΈ Database Agnostic: Widgets work seamlessly with MongoDB, PostgreSQL, MySQL, and MariaDB via abstract adapters.
- π Multilingual: Native support for
contentLanguagein all text-based widgets. - π§ͺ Testable: Standardized testing patterns for all pillars.
Widget Management Interface
Access /config/widgetManagement to:
- View system health and widget statistics.
- Enable/Disable widgets per tenant.
- Browse and install widgets from the Marketplace.
- Visualize the 3-Pillar implementation status.
π Related Resources
- Content Types: Using widgets in collections.
- API Development: Widget API integration.
- Security: Widget security considerations.