Skip to Content
Strapi Page Builder 1.0 is now available 🎉

Array

import { ComponentConfig } from "@wecre8websites/strapi-page-builder-react"; export interface MyComponentProps { myFieldName: { myArrayFieldName: string }[]; } export const MyComponentConfig: Omit<ComponentConfig<MyComponentProps, MyComponentProps>, "type"> = { fields: { myFieldName: { type: "array", label: "My Field Name", arrayFields: { myArrayFieldName: { type: "text", label: "My Array Field", }, }, min: 0, max: 6, getItemSummary: (item) => item.myArrayFieldName, defaultItemProps: { myArrayFieldName: "My Array Item" }, }, }, defaultProps: { myFieldName: [{ myArrayFieldName: "My Array Item" }], }, label: "My Component", render: (props) => { return <ul> {props.myFieldName.map((item, index) => <li key={index}>{item.myArrayFieldName}</li>)} </ul> } }

Field Definition

ParameterDescriptionRequired
typetexttrue
labelThe label for the field in the editor.false
arrayFieldsAn object defining the fields for each item in the array. Array fields are defined the same as component fields and can use any valid component field type.true
minThe minimum number of items in the array.false
maxThe maximum number of items in the array.false
getItemSummaryA function that returns a summary of the item used as the entry title in the editor.false
defaultItemPropsDefault values for new items.false

Field Appearance


Strapi Page Builder
Last updated on