Examples
Content model editor
Built with the mantine-form skill
Create content model
Build a form for creating a content model in a headless CMS. A model has a name, a key and a list of fields; content entries are later created from it.
Model:
- model name (required, 2–60 characters)
- model key (required, lowercase letters, digits and underscores; auto-filled from the name as a slug until the user edits it by hand)
- description (optional, 200 characters max)
Fields list:
- a list of fields, each shown as a row with type icon, label, key and a "required" marker; at least one field
- rows can be reordered with drag and drop (dnd-kit), edited and removed
- "Add field" opens a modal with a field type picker: Text, Rich text, Boolean, JSON, Select, Image, File, Reference — each with a one-line description
- after a type is picked, the same modal shows the field options form; Save adds the field to the list and closes the modal
- editing a field opens the same modal directly on the options form with the field values; Save updates the field
Field options (all types):
- label (required), key (required, slug auto-filled from the label until edited, unique within the model), description (optional), required checkbox
Type-specific options:
- Text: input or textarea, max character count (optional, 1–100000), default value
- Boolean: default value (true/false)
- JSON: default value validated as JSON
- Select: a list of value/label options (at least two, unique values) that can be reordered with drag and drop (dnd-kit), default option
- Reference: target model (select from a hard-coded list: Author, Category, Page, Product), "allow multiple" checkbox
- Rich text, Image, File: no extra options
Behavior:
- submitting with no fields shows the error under the list and focuses "Add field"
- on submit show a short success notification, display the model JSON (name, key, ordered fields with their options) under the form and keep the form as is
Write tests for the component.