Skip to main content

Add properties

This page shows you how to give a component values that each page can set.

You need a component, or any synced pattern.

Add a property​

  1. Open the synced pattern in the editor.
  2. In the Pattern tab of the sidebar, open the Component panel.
  3. Click + (Add property).
  4. Set its label, its type and its default.
  5. Use the property in the pattern's blocks by its name, as any dynamic data: {{ title }}.

A synced pattern open in the editor: a card on the canvas, beside the Component panel listing its properties and its slot

FieldWhat it does
LabelThe name a page sees above the field. A new property also takes its name from it.
NameThe name your blocks use: lowercase letters, numbers and underscores. A name that is taken is refused.
DescriptionOptional. Shows under the field on each page.
TypeThe field a page gets.
DefaultWhat shows when a page sets nothing.
OptionsFor a Select: one per line.

A property open on its fields: Label, Name, Description, Type and Default

A pattern placed with no value shows its defaults, so it always renders.

Make a property from what you wrote​

While you edit the pattern, a property can come from a block you already filled:

  • A text. Select the block, click Create property in its toolbar and type a name.
  • An attribute. Open the Data Picker of its field (href, src, id, class, a custom attribute), click New property and type a name.

A heading selected in the pattern, its Create property button pressed and the New property form open

The property takes what the field held as its default, and the field now reads {{ name }}. An href makes a Link property, anything else a Text property. For an image from your media library, add an Image property in the Component panel instead.

Create property is offered for a plain text, not for one that holds bold, a link or a line break. A textarea has it too.

In a pattern, the Data Picker lists the pattern's properties first, in a Properties group.

Property types​

The type sets the field a page gets for the property.

TypeFieldIn the HTML panel
TextText input'Our services'
NumberNumber input12
ToggleSwitchtrue or false
SelectList of the options you type, one per line'large'
ColorColor picker'#d63638'
LinkText input'/contact'
ImageMedia libraryget_image(12)
ExpressionText input, for data of any kindAny expression
Common mistake

Renaming a property does not update what uses it. The pattern's blocks that read the old name, and the pages that pass a value under it, keep the old name. Rename before you use it, or update the blocks and the pages yourself.

What a property is made of​

Each property is a Variable block at the root of the pattern, outside any other block. It reads its own name, with the default as a fallback:

{% set title = title ?? 'Card title' %}

<article class="card">
<h3>{{ title }}</h3>
</article>

A Variable you write yourself this way is a property too, and shows in the Component panel. Without a fallback, or inside another block, it is a plain variable.

Next steps​