Skip to content

Bricks

Bricks are a reusable way of defining groups of custom fields. In other systems, you may call these blocks or components.

To create a brick, simply import the BrickBuilder class and create a new instance of it. Using the builder pattern, you can chain custom field methods on the brick to define its structure.

Example

bricks/banner-brick.ts
import { BrickBuilder } from "@lucidcms/core/builders";
const Banner = new BrickBuilder("banner", {
details: {
name: {
en: "Banner",
},
summary: "A banner with a title and intro text"
},
preview: {
image: "https://placehold.co/600x400",
},
})
.addTab("contentTab", {
details: {
label: "Content",
},
})
.addText("title", {
details: {
summary: "The title of the banner. This is displayed as an H1 tag.",
},
validation: {
required: true,
},
})
.addWysiwyg("intro")
.addRepeater("callToActions", {
details: {
label: "Call to Actions",
},
validation: {
maxGroups: 3,
},
})
.addText("ctaTitle", {
details: {
label: "Title",
},
})
.addText("ctaUrl", {
details: {
label: "URL",
},
})
.endRepeater()
.addTab("configTab", {
details: {
label: "Config",
},
})
.addCheckbox("fullWidth", {
details: {
summary: "Make the banner full-width",
},
});
export default Banner;

Available Custom Field methods

  • addFields
  • addTab
  • addRepeater & endRepeater
  • addText
  • addWysiwyg
  • addMedia
  • addNumber
  • addCheckbox
  • addSelect
  • addTextarea
  • addJSON
  • addColour
  • addDateTime
  • addLink
  • addUser
  • addDocument