Outline basic information about your Element
The info.json file contains important information about a Component. The file uses the JSON format and consists of a series of key and value pairs. It's required for Component to function.
Every Component needs to define a category in which they belong. This tells Elements how to group components in the UI and helps users to locate components. Your Component MUST use one of the following pre-defined categories.
If you think we're missing a category, please visit the forum and let us know.
Accessibility
ARIA Lables, Contrast Checkers.
Animation
Hover Effects, Animated SVG's.
CMS
Content Management Systems
Content
Headings, Paragraphs, Lists.
Dynamic
Online Databases, Google Sheets.
Ecommerce
Cart Integration, Product display, Add to Cart Buttons.
Forms
Text Fields, Text Areas, Checkboxes, Buttons.
Interactive
Modals, Popovers, Accordions, Carousels.
Layout
Grid, Flex, Containers, Columns.
Media
Images, Video, Audio Players, Icons, Embeds (YouTube, Vimeo).
Navigation
Menus, Nav Bars, Breadcrumbs, Tabs.
Security
Password Protection, Login Forms.
SEO
Keywords, SEO helpers.
Utility
Cookies, Anchors, Placeholders, Dividers.
The Elements info.json file supports the following key-value pairs.
identifier (Required)
string
The identifier is the unique ID for your Element. We recommend using a reverse DNS format. This should be a string consisting of just lowercase characters and periods without spaces.
author (Required)
string
The name of the author of the Element. This would usually be the developer name, or the name of the company publishing the Element.
title (Required)
string
The name of the Element. This will be displayed inside of RapidWeaver. A unique and descriptive name is preferable. Overly long names will get truncated, check inside of the RapidWeaver UI for readability.
group (Required)
string
One of the above categories. Components with the same category are grouped together.
tags
array
A list of tags relevant to the Elements.
helpURL
string
A URL to the location of the help documentation online.
infoURL
string
A URL to the location of the marketing page online.
You can use the following code as a starting point for your own info.json file.
At a bare minimum you'll want to include PDF images for light mode icons so they can be used for all views where your Component appears within the RapidWeaver Elements UI.
All Elements require an icon.pdf file for light mode. If the dark-mode.pdf file isn't provided, icon.pdf will be used in Dark Mode.
icon.pdf (Required), 1:1 ratio, e.g. 128x128 (Square)
icon-dark.pdf (optional), 1:1 ratio, e.g. 128x128 (Square)
The Palette image should be named paletteIcon.pdf and paletteIcon-dark.pdf for Dark Mode. If the paletteIcon-dark.pdf file isn't provided, paletteIcon.pdf will be used in Dark Mode.
paletteIcon.pdf (Required), 1:2 ratio, e.g. 128x256 (landscape)
paletteIcon-dark.pdf (optional), 1:2 ratio, e.g. 128x256 (landscape)
All Icon files should be placed at the root of the Component alongside the info.json file.
Watch the short video below to learn more about adding custom icons to your Components.
Your pdf icons MUST be on a transparent background. The background should not be exported as this is generated in Elements.
We've provided an example Sketch document below you can use to get started.
There is some unfinished experimental support for banner style icons, these are great for layout style components. However, this style of icon may not be supported when Elements ships, please use with caution and ensure you also include the standard style of icon.
bannerLayer1.png
bannerLayer1-Dark.png (optional)
Banner icons can be layered, and each layer can represent a different colour in the Theme Studio. For example this icon uses four layers and three of those layers will be tinted with the Theme colour.
bannerLayer1.png
bannerLayer2-brand-500.png
bannerLayer3-brand-200.png
bannerLayer4-surface-500.png
Banner images should be 512px in width, but can be as short or tall as you need. Banner icons will appear the same in both grid and list.
The properties.json file defines the User Interface for an Element. Browse the UI Control docs for a full list of available controls.
Here's an example of setting Default Properites on various UI controls.
Groups allow you to organise similar settings into relevant groups.
Here is an example emtpy group:
You can specify an icon to appear next to the title of your group. The Icon property uses SF Symbols. Please refer to the SF Symbol app for a list of available icons.
Controls should placed inside of the properties array. The following example has a heading and an image drop well inside of the group.
The following example has two groups, the first with a text box, and the second with an image dropwell.
All properties have the same general structure using the following object keys.
In some cases, it's adventagous to format a value before it's passed to your element's templates. To achieve this, add a format
property to the configuration specifying the format string.
Value formatting is support by all controls.
For example, the following creates a slider ranging from 0-12 with a property called padding
If the slider is set to 5 and the template contains
the output will be
You could also format the control's value to use tailwind's arbitrary value feature. This would allow your element precis control over all css properties. For example, you can control the opacity utility class from tailwind with a slider:
If the slider is set to 50 and the template contains
the output will be
You could also format the control's value to output a valid CSS property. For example, if we want to control the translateX css property with a number input, we can do the following:
If the number field is set to 50 and the template contains
the output will be
Of cause, in this case you would want to add this to a CSS template file.
You can even use the format to control a CSS Custom Property (css variable). If we take our previous example and expand on it, we might want to instead set a --translateX
CSS custom property with a number input:
If the number field is set to 50 and the template contains
the output will be
In this case you would either want to add this to a CSS file, or use an inline style attribute to set the --translateX
:
The visible
key in an object's properties can be set using a logical expression that evaluates to true
or false
. This determines whether a specific UI element is shown or hidden based on the conditions specified in the expression. Works in the same way as enabled.
Boolean Logic: Use logical operators (&&
, ||
) to combine multiple conditions.
Comparison Operators: Use ==
, !=
, >
, <
, >=
, <=
to compare values.
Regex Match: Use matches
to perform a regex comparison.
Complex Condition
This makes the property visible only if the backgroundType is either custom' or 'image', and the textColor is 'white'.
Visibility Based on Numeric Ranges
Useful for showing elements that should only be visible within a specific range, e.g., showing a message if the opacity is not between 20-30.
Negation to Hide Elements
The property is visible when mySwitchControl
is false
.
Match a regex
The property is visible when name
contains rapid
or weaver
or elements
.
The following example code toggles the visibility of controls based on the value of the switch.
Show and hide controls based on another control's value.
The enabled
key in an object's properties can be set using a logical expression that evaluates to true
or false
. This determines whether a specific UI element is enabled or disabled based on the conditions specified in the expression. Works in the same way as visible.
Boolean Logic: Use logical operators (&&
, ||
) to combine multiple conditions.
Comparison Operators: Use ==
, !=
, >
, <
, >=
, <=
to compare values.
Complex Condition
This makes the property enabled only if the backgroundType is either custom' or 'image', and the textColor is 'white'.
Visibility Based on Numeric Ranges
Useful for enabling controls that should only be visible within a specific range.
Negation to Hide Elements
The property is enabled when mySwitchControl
is false
.
By default all properties in Elements are responsive, allowing users to override setting for different device breakpoints. Elements accomplishes this by prefixing Tailwind’s responsive modifiers to the control’s value. Let’s explore how this works in an example.
In this example, a select control uses Tailwind’s text transform utility classes. The user can customize the control’s value across device breakpoints by clicking the responsive icon (dot) to the left of the control title in Elements.
Initially, the headingTextTransform
property output is set to normal-case. However, once the user customizes this setting in Elements, it may look something like this: normal-case sm:uppercase md:lowercase lg:capitalize
.
Elements automatically applies and manages these responsive modifiers, saving you the effort of manually setting values for each device size and applying the appropriate modifier.
This even works for controls that require multiple classes as the value. So given the following control:
You can expect the output of position
to be bottom-0 left-0 right-auto md:top-0 md:left-auto md: right-0
To disable responsive values for your control, simply add "responsive": false
to your control. This allows you to use the raw value from a control.
All UI Controls need to be placed inside of a Group. The controls appear in the inspector.
Display a divider between content.
Displays a heading in the inspector interface.
Displays an image dropwell in the inspector.
Display some informational static text.
The Link control allows users to input a URL or link to another page within their RapidWeaver project.
The following will give you access to the link object in your template file(s).
By default the link attribute will return a relative URL. To get the full URL add the absoluteURL property.
Corresponding template example using the absoluteURL.
Displays a number field with a stepper.
Display a segmented control.
You can also use the following title key to display text instead of icons.
Supports responsive values
Displays a select box, also known as a dropdown menu. A select box can be responsive or non-responsive and has two or more items to choose from.
default
string
Value of the default item to be selected
title
string
The item title to be displayed in the dropdown
value
string
The value to be returned
The returned value is dependent on the responsive setting and either returns a string of tailwind classes or the raw value.
true
string of tailwind classes
false
raw string value
Below is an example of a typical responsive dropdown that returns one or more tailwind text transform classes, one for each device breakpoint.
A slider can be used for choosing from a range of values.
The following example displays a stepped slider with seven pre-defined values.
The following example displays a stepped slider with seven pre-defined values.
The following example has a minimum value of 0 and maximum of 100. The units are set to round, and display in the UI with a "%" after the number.
An example slider setting a star rating between 0 and 5.
Here's an example of an items
array in sliders so you can set custom values for each point in the slider.
The slider control supports the following options.
title
string
The name of the Slider. This will be displayed beside the UI element of RapidWeaver
id
string
The id for this control.
format
string
Can be used to apply additional formatting to the value. {{value}}
will be replaced with the selected value. See value formatting for more information.
default
string
The default value the slider should be set to.
min
number
The minimum value for the slider.
max
number
The maximum value for the slider.
units
string
The units string appears alongside the slider value in the user interface, but it is not included in the template output value.
round
boolean
If true an integer will be used instead of a floating point.
ticks
number
the number of ticks that will appear beneath the slider.
snap
boolean
is set to true, slider will snap to ticks
.
Displays a switch, similar to a checkbox in functionality.
The following examples returns a true or false value. Note that responsive
should be false
.
The following example returns a string value instead of true or false. Note that responsive
should be false
.
To display this value in a template file, use {{display}}
.
When using a switch responsively, trueValue and falseValue should be set to a Tailwind class name. You'll then receive a list of Tailwind classes within your template, prefixed for each breakpoint as necessary.
In the Template file you can do the following to display different html based on the value.
Displays a text field in the inspector.
Displays a multiline text area in the inspector.
Displays the Theme Studio Border Width control.
Displays the Theme Studio Border Radius control.
Displays the Theme Studio Color control.
For consistency and integration with the Theme Studio in RapidWeaver Elements, use the themeColor
attribute to specify all color options for your elements. This ensures that the color settings are centrally managed and adaptable to theme changes.
Usage of themeColor
:
default: Sets the initial or fallback color and brightness. In this case, the default color is black with a brightness value of 300.
Output Example: The format
key controls the output format of the customColor
property. In your template files, referencing {{customColor}}
with the example configuration above would output: text-black-300
.
Displays the Theme Studio Font control.
For effective theme integration in RapidWeaver Elements, it is recommended to use the themeFont
attribute to define all font family settings for your elements. This approach ensures that font preferences are coordinated with the overall theme settings, providing a consistent user experience.
Here’s a structured example for defining a font property:
Output Example: In your template files, referencing {{fontFamily}}
with the example configuration above would output: font-sub-heading sm:font-heading md:font-quote
.
Displays the Theme Studio Spacing control.
The themeSpacing
attribute is should be used for all space settings like padding, margins, gaps, translate, and positioning.
This control allows the user's site to dynamically adapt to any theme updates, changes, or overrides to the spacing scale.
The themeSpacing control has the following modes:
padding
margin
gap
transition
position
single
Each one of these modes correspond to the appropriate Tailwind utility classes. This means both developers and users can manage one single spacing scale that help promote consistency across all sites built in RapidWeaver Elements. See the examples below for more information.
The single mode allows you to access the spacing scale from the Theme Studio in a single select control. This is handy when you need to set a single property rather than all four properties (top, right, bottom left). For example, if you need to set only the top
css property you can do so like this:
In this example, the default value will be returned as top-2
.
You can also specify that a custom value should be used by default for the themeSpacing control. This allows you to gain precise control over the value of the spacing when your element is dropped on to a page.
Displays the Theme Studio Shadow control.
Displays the Theme Studio Text Style control.
Displays the Theme Studio Typography class picker.
Component Template Folder
Template files in RapidWeaver Elements house all the HTML, CSS, JavaScript, and other assets your component needs to work seamlessly. These files are dynamically processed by Elements, allowing for property replacements (think handlebars-style), perform iterations, and more—enabling you to build highly flexible and reusable components.
The structure of the templates directory is important and denotes in which area the contained files will be inserted into the page. Any files placed at the root of the templates directory will be processed and added for each instance of the component on the page.
The templates directory may also contain the following sub directories
headStart - placed at the top of head
headEnd - placed at the end of head
bodyStart - placed at the top of body
bodyEnd - placed at the bottom of body
include - files can be included from other template files using an @include statement
html - contains HTML content
js - contains javascript
css - CSS styles
php - files containing PHP
The portal feature allows you to transport sections of your template code to another part of the page.
If you are linking and including scripts, you'll want to tell Elements to only include the link once (when multiple instances of the same component are on the page). To do that you can use the "includeOne argument.
Include once across multiple components.
Deploy extra files to the backend.
Files added to the backend directory are processed in the same context as other template files. However, instead of forming part of the page, they will be deployed as extra files to the page's backend directory during publish.
To ensure there are no conflicts with other components, all backend files are stored in a subdirectory corresponding to the current node id. For example:
The following file types are supported:
html
php
js
css
A good use-case for this would be to process a contact form. Create a new component and add the following code to the templates/backend/submit.php
file.
Then place this in the templates/form.html
frontend file.
When the submit button is pressed in the above form, the form sends all the form values to the {{node.backendPath}}/submit.php
file on the server. The node.backendPath
property will be replaced with the node's unique id.
To use the node.backendPath
property, we'll need to use the hooks.js file. Create a hooks.js file in your component and add this.
Elements monitors every file in the backend directory for changes. This can cause problems when adding large php libraries with hundreds of files. A better solution is to add the php library to the Element pack's shared assets directory.
The assets are deployed only once after a component from the pack is added to the page. Use the hooks file to find the site assets path and pass it to the backend file.
We've found it good practice to keep the backend php files to a minimum and use them to build a minimal config object using the properties from the component. Then call a method included from a php file within site assets, passing in the config object.
Display content based on dynamic conditions.
Conditional statements in Elements allow you to control when content is displayed based on certain conditions. Using @if, @else if, and @else, you can define different outcomes depending on the values of variables. This is useful for showing or hiding content based on user settings, mode (edit or preview), or other dynamic conditions.
The following example displays the text inside of the IF statment when the switch is on/true. It's worth noting that only non-responsive controls can be used in 'if' statements.
Elements lets you use the ! symbol to check if something is false. For example, @if(!edit) means ‘if edit mode is not active.’ This is useful when you only want to show something when a condition is not true. The ! can be used with any true or false value.
Elements allows you to specify a number of else if statements to run before falling back to the else block. An @elseif
statement works just like a regular @if
statement and follows the same syntax.
Elements gives you access to the current RapidWeaver mode inside of conditional statements. This can be particularly useful for showing content in edit mode or in preview.
RegEx (Regular Expression) is a powerful tool for searching, matching, and manipulating text based on specific patterns. It uses a combination of characters, meta-characters, and quantifiers to define complex search criteria. RegEx is widely used in programming, text editors, and command-line tools for tasks like input validation, pattern extraction, and string replacement. Its versatility allows users to efficiently find and process text, from simple matches to intricate parsing operations.
In Elements it can be used to conditionally check for values, the following example checks for specific words in a text field before showing a slider.
Elements gives you access to the current RapidWeaver mode inside of conditional statements. This can be particularly useful for showing content in edit mode or in preview when a certain property evaluates to true.
::index
::isFirst
::isLast
Include content from another template file
An include allows you to insert the content of another template file within the current template file.
Include files should be stored in the include directory.
Suppose you have the following template files in your include folder:
hello.html
world.html
You could then include the contents of those files into your main template.html file by using the following code:
The output from template.html would look like this
The include template files allow access to properties as if they were part of the main template file. Given that you have set a pages
value in your hooks file (via the rw.setProps()
method), you can pass that property to your template like so:
You can of cause include multiple properties simply by comma separating them:
Rather than wrapping your @include statement inside an @if statement, you can use the @includeIf helper:
info about the new @resource
(or will it be @image()
Setting an anchor in a template file will list it and allow it to be linked to from the Link Panel in the Editor.
And using a property:
Adding the @raw()
tag around templte content will stop Element properties from being processed.
The following tags should be placed in the html template file. Using any of the following tags enable editable areas with the page. No setup of configuration in the properties file is required.
Add a simple editible text area with optional default text.
An editable text area with a default value of "Hello World!".
Adds a text area that support the Typography feature.
A dropzones is an area within a template where child element can be added. Each dropzone requires a name giving you a consistent & reliable way to manage child items.
Sometimes you want to allow the user to drop the resources directly into the Editor, this can be achieved with the rwResourceDropZone
key.
The following example shows how to support dropping a folder of images directly into the Editor. Place the following in the Template HTML:
You also need a corresponding image control in the Properties file:
At the start of a template file you can add an inline template that can be included like any other template file. This is handy if you have small parts of your template you want to extract, and don't want or need to create separate templates files.
Assets can be included per component or shared in a component pack. Assets are additional files that should be deployed when a project is published. They are not processed in any way and are simply copied during publish.
All assets should be placed inside a directory named page and will be deployed once to the page's files directory during publish. Here's an example showing where to place the snowstorm.js file.
To link to an asset in a single component you'll need to do the following;
Use the {{assetPath}} macro inside of the index.html Template file. If you need the include to appear in the head (or other areas) of the page you can use the Portal Function.
Include the following code in the hooks.js to return the assetPath to the page template:
Hooks provide a powerful way to extend your components by manipulating properties before they are applied within templates.
The typical flow of a component follows this sequence: properties → hooks → template. Hooks process and refine properties, allowing you to perform complex logic before passing them into the template for rendering.
To use a transform hook, create a hooks.js
file in the root of your component with this code.
Next, add this to the template.html
file in the component templates directory.
rw:mode
string
edit
or preview
getValues
getClassNames
getResponsiveValues
getBreakpoints
getBreakpointNames
in hooks.js
in template.html
The rendered output would look something like this:
Mario - Plumber
The transform hook allows you to get and set property values before they're used in templates. Let's assume you have the following slider defined in your properties and you're using the value in a template.
When the slider is set to 5, the output would be
Now lets add a transform hook that multiplies the padding value by 2
With the slider still set to 5, when the template is processed the output will be
This becomes incredibly powerful and convenient when you need to perform logic based on multiple properties. The following example show how you might generate a list of css classes based on standard or custom settings.
The template simply uses the classes property instead of attempting to handle all options from 7 different properties. For example
Access Project Properties
Properties from the current environment can be used within templates but most of them need to be passed through using the setProps
command in the hooks.js file first. The node object is always available.
With this in place, we gain access to the following within template files.
{{project.title}}
String
{{project.mode}}
String
{{project.siteURL}}
String
{{project.language}}
String
{{project.enableSocialTags}}
Boolean
{{project.allowDarkMode}}
Boolean
{{project.logo.url}}
String
{{project.logo.alt}}
String
{{page.id}}
String
{{page.title}}
String
{{page.menuTitle}}
String
{{page.filename}}
String
{{page.ext}}
String
{{page.language}}
String
{{page.absolutePath}}
String
{{page.docRootPath}}
String
{{page.projectResourcesPath}}
String
Path to the project resources
{{page.isFolder}}
Boolean
Does this page represent a folder
{{page.displayInMenu}}
Boolean
Should the page be shown in menus
{{page.isDraft}}
Boolean
Draft pages are not published
{{page.icon.url}}
String
Path to the page icon
The node object is always passed into templates and contains the following properties.
{{node.id}}
String
{{node.title}}
String
{{node.parent.id}}
String
{{node.parent.container}}
String
{{node.backendPath}}
String
Path to the node's backend folder.
{{component.title}}
String
{{component.group}}
String
{{component.version}}
Integer
{{component.build}}
Integer
{{component.assetPath}}
String
Path to component assets
{{component.siteAssetPath}}
String
Path to component site assets
{{component.sharedAssetPath}}
String
Path to pack shared assets
The following template example will output the page (and folder) details for all the pages in a project.
Before you can access the page properties you'll need to include the following code in the Hooks.js