Skip to content

SDC components - Props

Props allow SDC components to define configurable inputs that users can configure in the Canvas interface. Each prop specifies its type, validation rules, and provides example values.

Props can be used to:

  • Insert content (text, images, etc.)
  • Configure component appearance (colors, alignment, state)
  • Control component behavior (animations, interactions)

Canvas automatically generates a form based on the props.

Basic text input for short text content.

Schema Definition:

title:
type: string
title: 'Component title'
examples: ['Hello World']

Twig Usage:

<h2>{{ title }}</h2>

Rich text editor for formatted content with HTML markup.

Schema Definition:

content:
type: string
title: 'Rich text content'
contentMediaType: text/html
x-formatting-context: block
examples: ['<p>This is <strong>formatted</strong> text</p>']

Twig Usage:

<div class="content">
{{ formatted_content }}
</div>

Textarea input for longer text content that spans multiple lines.

Schema Definition:

description:
type: string
title: 'Description'
$ref: json-schema-definitions://canvas.module/textarea
examples: ['A longer description\nthat spans multiple lines']

Twig Usage:

<div class="description">
{{ description|nl2br }}
</div>

Checkbox input for true/false values.

Schema Definition:

show_image:
type: boolean
title: 'Show image'
examples: [true]

Twig Usage:

{% if show_image %}
<div class="image-section">...</div>
{% endif %}

Numeric input with optional validation constraints.

Schema Definition:

spacing:
type: integer
title: 'Spacing in pixels'
minimum: 0
examples: [20]

Twig Usage:

<div style="padding-top: {{ spacing }}px">
Content with spacing
</div>

URL input for internal or external links. Choose the format based on what you accept:

  • format: uri — Absolute URLs only. The value must include a scheme (e.g. https://example.com, internal:/node/1). Use when the link must always be a full URI.
  • format: uri-reference — Absolute or relative. The value may be a full URI or a path such as /about or ../page.html. Use when relative paths or mixed link types are allowed.

format: iri and format: iri-reference behave the same as uri and uri-reference.

A link prop must use one of these formats. Without it, content templates cannot map the prop to a link field or to the URL of the content entity.

Schema Definition (absolute only):

link:
type: string
format: uri
title: 'Link URL'
examples: ['https://example.com/path']

Schema Definition (absolute or relative):

link:
type: string
format: uri-reference
title: 'Link URL'
examples: ['/about', 'https://example.com']

Twig Usage:

<a href="{{ link }}">Link text</a>

Renders as a dropdown with predefined options. Use meta:enum to customize display labels:

Schema Definition:

alignment:
type: string
title: 'Text alignment'
enum: ['left', 'center', 'right']
meta:enum:
left: Left aligned
center: Center aligned
right: Right aligned
examples: ['center']

Twig Usage:

<h2 class="heading heading--{{ alignment }}">
</h2>

Image selection from media library or image upload.

Schema Definition:

image:
title: 'Component image'
$ref: json-schema-definitions://canvas.module/image
type: object
examples:
- src: '/path/to/image.jpg'
alt: 'Component image'
width: 800
height: 600

Twig Usage:

{% include 'canvas:image' with image only %}

Date picker input for selecting dates.

Schema Definition:

event_date:
type: string
format: date
title: 'Event date'
examples: ['2024-12-25']

Twig Usage:

<time datetime="{{ event_date }}">
{{ event_date|date('F j, Y') }}
</time>

Date and time picker input for selecting a date with a time.

Schema Definition:

event_start:
type: string
format: date-time
title: 'Event start'
examples: ['2016-09-16T20:20:39+00:00']

Twig Usage:

<time datetime="{{ event_start }}">
{{ event_start|date('F j, Y H:i') }}
</time>

Email input for an email address.

Schema Definition:

contact_email:
type: string
format: email
title: 'Contact email'
examples: ['hello@example.com']

Twig Usage:

<a href="mailto:{{ contact_email }}">{{ contact_email }}</a>

The format keyword on a string prop selects the widget and validation. Canvas supports these formats:

Format Widget Accepted values
date Date picker A date, for example 2024-12-25.
date-time Date and time picker A date and time (RFC 3339), for example 2016-09-16T20:20:39+00:00.
email Email An email address, for example hello@example.com.
idn-email Email An internationalized email address.
uri Link An absolute URI, for example https://example.com.
uri-reference Link An absolute URI or a relative path, for example /about.
iri Link Same as uri.
iri-reference Link Same as uri-reference.

These formats are part of JSON Schema, but Canvas does not support them: time, duration, hostname, idn-hostname, ipv4, ipv6, uuid, uri-template, json-pointer, relative-json-pointer, and regex. A component with a prop that uses one of these formats is not available in Canvas.

The uri, uri-reference, iri, and iri-reference formats also accept:

  • x-allowed-schemes: limits the URI schemes, for example [http, https].
  • contentMediaType: limits the target to a media type, for example image/*. See Image.

List input allowing multiple values.

Schema Definition:

numbers:
type: array
title: 'List of numbers'
items:
type: string
maxItems: 10
examples: [['One', 'Two', 'Three']]

Twig Usage:

{% for number in numbers %}
<span class="number">{{ number }}</span>
{% endfor %}

For a comprehensive overview of all available prop types and their widgets, refer to the “All-Props” Test SDC module which demonstrates every supported prop type with examples.

Boolean, strings with different formats Integer, image, video, array of integers Enriched HTML
Boolean and string Integer, image, video Array of integers String, text with HTML