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 page | The Custom Code component - no setup |
| Change how a built-in component looks or works, for one project | Customize a core component in the Component Editor |
| Make a new, reusable section with its own settings | Create 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.
- Core Components - the built-in library. Edit one to customize it for this project; it's then marked Modified, and Restore puts back the original.
- Your Custom Components - components you created. Edit or Delete them.
- Create Component - start a new one (step by step below).
- Copy - copy a component to another project you manage.
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):
| File | What it does |
|---|---|
manifest.json | The component's name, group, description, and its settings - the fields that appear in the Page Builder's side panel. |
{id}.html | The starting markup, placed on the page before your script runs. Keep it neutral - see "Writing safe component code". |
{id}.css | The component's styles. |
{id}.js | The script that turns the settings into the finished section. |
component.sbn | An 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
- The page includes the component's
{id}.html, and loads its.cssand.jsonce (even if the component is used several times). - Nichols Software then calls your script's init function, named
init_plus your ID with dashes turned into underscores -custom-promo-bannerbecomesinit_custom_promo_banner. - It passes the component's element and its settings:
init_custom_promo_banner(element, props).propshas one entry per setting in your manifest, by itskey. - 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" } ]
}
}
}
| type | Field it shows |
|---|---|
text | One line of text |
textarea | Several lines of plain text |
richtext | Formatted text (bold, links, lists) |
number | A number (add min, max, step if you like) |
toggle / checkbox | On / off |
select | A choice from options (each with a value and label) |
color | A color picker |
repeater | A list of items; its fields describe one item (cards, slides, questions) |
group | A 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
- In the Component Editor, under Create Component, enter the name Promo Banner and the ID
promo-banner(Nichols Software addscustom-for you), then Create. - Open its manifest.json tab and paste the manifest above.
- Set {id}.html to a neutral starting point:
<div class="custom-promo-banner" data-root></div> - 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; } - Write the init function in {id}.js:
(function () { "use strict"; function esc(v) { return String(v == null ? "" : v) .replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">") .replace(/"/g, """).replace(/'/g, "'"); } 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>'; }; })(); - Save, then Preview.
- 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
- Escape every setting before putting it into HTML (the
escfunction above). Settings are typed by whoever edits the page; escaping stops stray<characters - or a pasted script - from breaking the page. - Block
javascript:links in any URL setting (safeUrlabove). - Keep the starting HTML neutral. Search engines and visitors with scripts turned off see it as written, so don't put sample ratings, claims, or placeholder contact details there - leave it empty and let your script fill it in.
- Rebuild, don't append. Set
el.innerHTML(or clear the element) at the start of every call. - Prefix your CSS with the component's ID so it can't restyle other parts of the site.
- Avoid globals. Wrap the file in a function as shown; only
window.init_...needs to be global.
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
- Changes take effect as soon as you save - reload the Page Builder or the page to see them.
- Custom and customized components belong to their project. Use Copy to bring one into another project.
- Your custom and customized components are included when you export the project to self-host it, and work there exactly as they do on Nichols Software.
- The built-in library itself can only be changed by Nichols Software administrators, because it's shared by every site.