Get started
Documentation menu

Reference

Field types

The controls the inspector can show for a block's props.

Each entry in a block’s fields describes how one prop is edited. All fields share these members:

Member What it is for
name The prop’s name, or the item prop’s name inside a list.
label The control’s label.
help A short hint under the control.
group The inspector group: “Content” (the default), “Actions”, “Settings” or any name you like.
optional The inspector offers to clear the value. Make the Zod prop .optional() too.

The types

type Edits Extra members
text A single line. placeholder, inline (edit in the preview)
textarea Several lines of plain text. rows, inline
richtext Markdown. Render it with renderMarkdown from @vamped/editor/blocks, which shows raw HTML as text and drops unsafe links.
image An image from Sveltia’s media library, or a URL. Use imageSchema. altField: the name of a sibling text field with the alt text
link A button or link: { text, href, newTab? }. Use linkSchema, which accepts paths (/about), anchors (#faq) and full https:// URLs.
color A colour. Use colorSchema. presets: colours to pick from
number A number. min, max, step, unit
boolean On or off.
select One of a fixed list. Use z.enum with the same values. options: { value, label, icon? }, where icon names an icon from your site config
list A list of small objects, such as features or questions. itemLabel, summaryField (the item field shown as its title), fields, defaultItem, min, max

A list, in full

{
  name: 'items',
  label: 'Questions',
  type: 'list',
  itemLabel: 'Question',
  summaryField: 'question',
  min: 1,
  max: 20,
  defaultItem: { question: 'A new question?', answer: 'Its answer.' },
  fields: [
    { name: 'question', label: 'Question', type: 'text', inline: true },
    { name: 'answer', label: 'Answer', type: 'textarea', inline: true },
  ],
}

In the component, mark each item and its fields with paths such as items.0 and items.0.question, so clicking them in the preview selects them.