Skip to main content
A component is a type name plus a renderer. The row stores { id, type, props }; the page template looks the type up in the registry and hands the renderer the props. The renderer emits HTML with anchors on it, and those anchors are what make it editable. There is no field schema to write: the fields are whatever the renderer anchors.

1. Build the renderer

src/components/<area>/Callout.astro. Group by where it lives in the site: home/, about/, careers/, global/.
What each part does: Two rules that matter in edit mode:
  • Render the stored value as it is. No truncating, no reformatting. The editor compares what is on screen with what is stored.
  • Anchor the element that holds the text, not a parent. That exact element becomes editable.
A field the design does not show, such as a link target or a toggle, has no anchor. It is edited from the section’s cog instead. See Page schemas.

2. Register it

src/lib/components.ts maps the stored type to the renderer. The key is exactly what the row will store.
An unknown type renders nothing, so a typo here is a blank section, not an error.

3. Put it on a page

Two ways, and a page can use both. Fixed. Always there, editors cannot remove it. One line under the page’s sections:
The key becomes the component’s id. props are what the section holds until someone edits it. Addable. Editors add it from the tab on the right, and can reorder and remove it. An entry in the page’s palette:
starter is what a fresh block stores. Text fields start as "". A media slot is the pair image and imageVideo, both "".

4. Run dev

A fixed section renders on the next dev start, empty until someone types. A palette entry appears on the tab in Edit mode. Either way, click a field in /admin and it is editable.

If the component has a list

A row of logos, cards or team members inside the component is an array. Its items are editable with anchors. Adding, reordering and removing need one schema entry. See Make a list addable.

If it renders on two pages

A value with one home shown in two places, such as a stat on the home page that belongs to a case study, is anchored with stageRef instead of stagePath. The editor saves to the one row. See Shared content.

Next steps

Components

The full renderer contract.

Edit anchors

Every attribute and helper.