← Page Builder

Creating Custom Components

The built-in components cover most pages. When you need a section that looks or behaves exactly your way, you have three options - pick the lightest one that does the job:

You want to...Use
Drop one embed, widget, or snippet on a single pageThe Custom Code component - no setup
Change how a built-in component looks or works, for one projectCustomize a core component in the Component Editor
Make a new, reusable section with its own settingsCreate a component in the Component Editor

Option 1: the Custom Code component

Add Custom Code to a page and paste in HTML, CSS, and JavaScript. Use its Advanced tab to load an outside script or stylesheet by URL - for example one stored in your project's Project Files. Outside code doesn't run inside the Page Builder canvas unless you turn on its matching "Run ... in Builder canvas" option, so a misbehaving script can't break the editor. Custom Code is best for one-offs; if you find yourself pasting the same thing on several pages, make it a component instead.

The Component Editor

On the Projects page, select a project and choose Open Component Editor. The editor works on that one project: everything you change there affects only that project's site. You need to be the project's Owner or a Team Admin on it.

Inside a component, the editor has a tab for each file, plus Save, Preview, and Backups. Every save keeps a backup of the previous version, so you can always step back.

What a component is made of

Each component is a small folder of files, named after its ID (for example custom-promo-banner):

FileWhat it does
manifest.jsonThe component's name, group, description, and its settings - the fields that appear in the Page Builder's side panel.
{id}.htmlThe starting markup, placed on the page before your script runs. Keep it neutral - see "Writing safe component code".
{id}.cssThe component's styles.
{id}.jsThe script that turns the settings into the finished section.
component.sbnAn older template format. Current pages don't use it; you can leave it as the editor creates it.

How a component appears on a page

  1. The page includes the component's {id}.html, and loads its .css and .js once (even if the component is used several times).
  2. Nichols Software then calls your script's init function, named init_ plus your ID with dashes turned into underscores - custom-promo-banner becomes init_custom_promo_banner.
  3. It passes the component's element and its settings: init_custom_promo_banner(element, props). props has one entry per setting in your manifest, by its key.
  4. In the Page Builder, the init function is called again every time a setting changes, so it must rebuild the section from scratch each time rather than add to what's already there.

Settings (manifest.json)

Each entry in propsSchema becomes a field in the side panel:

{
  "id": "custom-promo-banner",
  "title": "Promo Banner",
  "group": "custom",
  "icon": "megaphone",
  "version": 1,
  "description": "A bold one-line promotion with a button.",
  "propsSchema": {
    "message":    { "key": "message", "type": "text", "label": "Message", "default": "" },
    "buttonText": { "key": "buttonText", "type": "text", "label": "Button text", "default": "" },
    "buttonUrl":  { "key": "buttonUrl", "type": "text", "label": "Button link", "default": "" },
    "theme": {
      "key": "theme", "type": "select", "label": "Theme", "default": "dark",
      "options": [ { "value": "dark", "label": "Dark" }, { "value": "light", "label": "Light" } ]
    }
  }
}
typeField it shows
textOne line of text
textareaSeveral lines of plain text
richtextFormatted text (bold, links, lists)
numberA number (add min, max, step if you like)
toggle / checkboxOn / off
selectA choice from options (each with a value and label)
colorA color picker
repeaterA list of items; its fields describe one item (cards, slides, questions)
groupA set of related fields shown together; list them in fields

Add "help" to any field to show a hint under it. "default" is the value a new copy of the component starts with.

Step by step: a promo banner

  1. In the Component Editor, under Create Component, enter the name Promo Banner and the ID promo-banner (Nichols Software adds custom- for you), then Create.
  2. Open its manifest.json tab and paste the manifest above.
  3. Set {id}.html to a neutral starting point:
    <div class="custom-promo-banner" data-root></div>
  4. Add the styles in {id}.css - prefix every class with your ID so nothing clashes with the rest of the site:
    .custom-promo-banner { padding: 24px; border-radius: 12px; display: flex; gap: 16px; align-items: center; justify-content: space-between; }
    .custom-promo-banner--dark  { background: #1c2f38; color: #fff; }
    .custom-promo-banner--light { background: #f4f6f8; color: #1c2f38; }
    .custom-promo-banner__btn   { padding: 8px 16px; border-radius: 8px; background: #c98530; color: #fff; text-decoration: none; }
  5. Write the init function in {id}.js:
    (function () {
        "use strict";
    
        function esc(v) {
            return String(v == null ? "" : v)
                .replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
                .replace(/"/g, "&quot;").replace(/'/g, "&#39;");
        }
    
        function safeUrl(v) {
            var url = String(v || "").trim();
            return /^\s*javascript:/i.test(url) ? "#" : url;
        }
    
        window.init_custom_promo_banner = function (el, props) {
            props = props || {};
            var theme = props.theme === "light" ? "light" : "dark";
            var message = String(props.message || "").trim();
            var buttonText = String(props.buttonText || "").trim();
    
            // Rebuild everything each call - the Page Builder calls this on every edit.
            el.innerHTML =
                '<div class="custom-promo-banner custom-promo-banner--' + theme + '">' +
                    '<strong>' + esc(message || "Your promotion here") + '</strong>' +
                    (buttonText
                        ? '<a class="custom-promo-banner__btn" href="' + esc(safeUrl(props.buttonUrl)) + '">' + esc(buttonText) + '</a>'
                        : '') +
                '</div>';
        };
    })();
  6. Save, then Preview.
  7. Open the Page Builder for the same project: Promo Banner is in the component library under Custom. Add it to a page and fill in its settings.

The built-in Custom Callout Card is a complete working example of the same pattern - open it in the Component Editor to read its files.

Writing safe component code

Customizing a built-in component

Choose Edit next to a core component to change it for the current project only - every other project keeps the original. The same files and init function apply. If you change a setting's key, pages that already use the component keep the old value under the old key, so prefer adding new settings over renaming existing ones. Restore brings back the built-in version at any time.

Good to know