For the complete documentation index, see llms.txt. This page is also available as Markdown.

Make your first section

In this tutorial, you'll build a hero banner section with a background, title, description, image, and a call-to-action button. By the end, you'll understand how Crane sections are structured and how content and design composables work together.

What You're Building

A hero banner that a store owner can customize through the Lightspeed editor:

  • Background — solid color or gradient

  • Title — customizable text, font, size, and color

  • Description — multi-line text with styling

  • Image — responsive hero image

  • CTA Button — configurable label and link

Download Assets

This tutorial uses sample images for the hero banner and showcase. Download them and keep them ready — you'll copy them into the right directories as you go:

  • hero_webp-2000x1500.jpeg — high-resolution hero image

  • hero_webp-200x150.jpeg — low-resolution hero image

  • hero_banner_section_showcase_1_preview.jpeg — showcase preview thumbnail

  • reference_template_cover_image.jpeg — template cover image

Scaffold the Section

From your application root, generate a new section:

This creates the following structure inside sections/hero-banner/:

Let's walk through the key files.

Entry Points

server.ts

The SSR entry point creates the Vue app on the server:

client.ts

The client entry point hydrates the server-rendered HTML in the browser:

Both entry points pass the Content and Design types as generics, ensuring full type safety across the SSR pipeline. These files rarely need changes beyond updating the component import.

Define Content Settings

Edit settings/content.ts to define what the store owner can edit. For our hero banner, we need a title, description, image, and button:

Each key becomes a content editor field in the Lightspeed admin panel. The content builder provides typed factory functions for each editor type. Labels use translation keys (defined in translations.ts) for i18n support.

Define Design Settings

Edit settings/design.ts to define the visual customization options:

The design builder provides factory functions for each design editor type. You can specify allowed colors, font sizes, and defaults. These give the store owner control over fonts, colors, and the section background through the Lightspeed editor.

Define Translations

Edit settings/translations.ts to provide the human-readable strings for every $label.* key used in your content and design settings. Each language is a separate object keyed by locale code:

Every $label.* key referenced in content.ts and design.ts must have a corresponding entry here. The translation.init() builder takes an object keyed by locale code (en, nl, fr, etc.) — each locale maps every $label.* key to its translated string. This is what the store owner sees in the Lightspeed editor UI.

Locales

The scaffolded section comes with en, nl, and fr locales pre-configured. You can add more locales by adding additional keys to the object.

Define Layout

Edit settings/layout.ts to define the available layouts for your section. Each layout is a different arrangement of the section's content — for example, text overlaid on an image vs. text below the image. For a getting-started hero banner, a single layout with empty overrides is sufficient:

The file exports an array of layouts created with layout.init(). Each layout has:

  • layoutId — a unique identifier for the layout

  • selectedContentSettings — content setting overrides for this layout (empty means use the defaults from content.ts)

  • selectedDesignSettings — design setting overrides for this layout (empty means use the defaults from design.ts)

Design Overrides

Layouts let you offer multiple visual variations of the same section. When selectedDesignSettings is empty, the layout uses the base design settings as-is. You can add overrides with layout.designOverride.text(), layout.designOverride.background(), etc. to customize defaults per layout.

Type Definitions

Edit type.ts to infer TypeScript types from your settings:

Global Types

InferContentType and InferDesignType are globally available — no import needed.

Build the Component

Now for the main part — edit ExampleSection.vue to bring everything together:

Key patterns to note

  • Content composables (useInputboxElementContent, useImageElementContent, etc.) return reactive data from the store owner's editor input

  • Design composables (useTextElementDesign, useBackgroundElementDesign, etc.) return style settings like font, color, and visibility

  • hasContent and visible — always check these before rendering to handle empty or hidden elements

  • (titleDesign.color as Color).hex — color properties may be global color strings or Color objects, so cast when accessing .hex

  • Settings use builder functionscontent.inputbox(), design.text(), etc. imported from @lightspeed/crane-api

  • Translation keys — labels use $label.* keys defined in settings/translations.ts for i18n support

Define a Showcase

Showcases are preview presets that demonstrate your section with pre-filled content and design values. They appear in the Lightspeed editor when a store owner browses available sections. You need at least one showcase.

Create showcases/1.ts:

Key things to note:

  • showcase.init() — creates a showcase with a unique showcaseId

  • previewImage — a preview thumbnail shown in the editor (place the image in assets/). Include width and height to control the preview card's aspect ratio

  • blockName — the display name (uses a translation key)

  • layoutId — must match a layout ID defined in settings/layout.ts

  • content / design — use content.default.*() and design.default.*() builders (note: default namespace, not the same builders as in settings)

  • Content and design keys must match the keys in your settings/content.ts and settings/design.ts

Cleanup

You should remove 2.ts and 3.ts from the showcases/ folder. We don't need them for this section.

Showcase Translations

Create showcases/translations.ts with the translated strings for the showcase:

Translation Scope

Showcase translations are separate from section translations. Section translations (settings/translations.ts) provide labels for the editor UI, while showcase translations (showcases/translations.ts) provide the pre-filled content values for each showcase.

Learn more

  • Sections — Master your knowledge on section components and configurations

  • Section collections — Create redistributable section packages

Last updated

Was this helpful?