A custom section is a TSX file whose default export is defineSection. Add one from Website editor → Add section → Custom section, or generate one and then edit the source.
The id inside the file is cosmetic. Lockii stores the section as custom. plus a generated id, and the page uses that stored id.
Saved page sections are listed under Custom. The category string in the file does not pick a different group.
A copy section
import {
defineSection,
fields,
SiteContainer,
SiteHeading,
} from "@lockii/site-sdk";
export default defineSection({
id: "custom.starter",
label: "Custom section",
category: "Custom",
fields: {
headline: fields.text({ label: "Headline", ai: { rewrite: true } }),
body: fields.textarea({ label: "Body", ai: { rewrite: true } }),
},
defaults: {
headline: "Your headline",
body: "Tell customers what makes you different.",
},
render: ({ headline, body }) => (
<section className="sec-section">
<SiteContainer>
<SiteHeading level={2}>{headline}</SiteHeading>
<p style={{ color: "var(--site-paragraph)" }}>{body}</p>
</SiteContainer>
</section>
),
});fields become sidebar controls. defaults are the values a new section starts with. render receives those values as props. ai: { rewrite: true } lets Lockii rewrite that copy.
Wrap the section in <section className="sec-section"> and put the content in SiteContainer so it shares the site width.
A product grid
import {
defineSection,
fields,
SiteContainer,
SiteHeading,
SiteProductCard,
useProducts,
} from "@lockii/site-sdk";
export default defineSection({
id: "custom.starter",
label: "Custom products",
category: "Custom",
fields: {
headline: fields.text({ label: "Headline", ai: { rewrite: true } }),
limit: fields.number({ label: "How many products" }),
},
defaults: {
headline: "Popular gear",
limit: 6,
},
render: ({ headline, limit }) => {
const products = useProducts({ limit });
return (
<section className="sec-section">
<SiteContainer>
<SiteHeading level={2}>{headline}</SiteHeading>
<div
style={{
display: "grid",
gap: "var(--site-item-spacing)",
gridTemplateColumns: "repeat(auto-fill, minmax(240px, 1fr))",
}}
>
{products.map((product) => (
<SiteProductCard key={product.id} product={product} />
))}
</div>
</SiteContainer>
</section>
);
},
});useProducts reads the company catalog. SiteProductCard paints each product with the theme card layout, price, and booking button. A product that is free at a nearby site and not at the selected one shows Available nearby and stays unavailable for checkout here.
A button
cta: fields.action({ label: "Button" }),defaults: {
cta: { type: "browse", label: "Browse gear" },
},<SiteButton action={cta}>{cta.label}</SiteButton>fields.action stores a label and a destination. SiteButton follows that action: browse, a product page, a site page, an external URL, a phone number, or an email.
A form
Use SiteForm. Raw <form> and <input> tags are still blocked.
<SiteForm
formId="quote-request"
formName="Quote request"
fields={[
{ type: "text", label: "Name", required: true },
{ type: "email", label: "Email", required: true },
{ type: "textarea", label: "Message", required: true },
]}
submitLabel="Send message"
/>Submissions land in the staff inbox under the Form name. See Components for SiteFormRoot and the field types, and Website forms for the inbox side.
On the page
Select the section. The fields from the file are at the top of the sidebar. Background, Padding, and Custom CSS follow.
Background is Color, Gradient, or Image. Padding is Top and Bottom.
A block nested inside another section does not get Background or Padding.
The website assistant can change those fields the same way it changes a built-in section. It will not save a custom section that throws when it renders, has a field or stylesheet the checker rejects, or names an icon that is not in the picker. It will not publish a page when a custom section on it throws with the values saved on that page. That section would show as a blank band. Fix the code, or the sidebar values, then publish again.
Saving the source updates every page that uses the section, including pages already on the site. Each save keeps the code from before it. Saves within 30 seconds count as one version. The website assistant can roll the code back. The code it replaces is kept, so the rollback can be undone. It will not remove the section from the library while a page draft, a published page, or the header or footer still uses it.
Definition fields
Field | Role |
|---|---|
| Cosmetic. The page uses the stored |
| Name in the editor sidebar. |
| Kept in the file. Saved page sections still show under Custom. Use |
| Sidebar controls, built with |
| Starting values. Keys match |
| React function. Props match |
| Optional stylesheet for every copy of the section. Scoped like Custom CSS. |
|
|
| Optional list of page types this section can be added to. |
Page types include home, custom, product_template, location_template, category_template, blog_template, blog_index, locations_index, account_template, and checkout_template.
css allows selectors, @media, @supports, @container, and var(--site-*) colors. It cannot use url(), and it cannot assign a --site-* variable. Custom CSS on one section is added after this shared sheet. See Theme and sandbox.
Save and publish
The preview updates as the file compiles. Fix the errors listed under the editor before saving. A page that uses the section can be published once the definition is ready.
A file can be up to 30,000 characters. Duplicate a built-in section when you want its layout as the starting point, then change the source.
