Skip to main content

Container

Container Field Properties

The container field type allows you to group and arrange other fields in a grid layout with customizable columns, gaps, and styling options.

Basic Usage

{
fieldId: "basic_container",
type: "container",
columns: 2,
fields: [
// your fields here
]
}

Props

PropTypeDescriptionDefault
asstringHTML element to use as container"div"
columnsnumberNumber of columns in the grid1
gapnumberGap between grid items in pixels16
fieldsarrayArray of fields to render inside container[]
containerStylesCSSPropertiesStyles for the outer containerundefined
containerClassNamestringClass name for the outer containerundefined
stylesCSSPropertiesStyles for the grid containerundefined
classNamestringClass name for the grid containerundefined
itemsStylesCSSPropertiesBase styles for all grid itemsundefined
itemsClassNamestringBase class name for all grid itemsundefined
headerReactNodeHeader content to render above gridundefined
footerReactNodeFooter content to render below gridundefined
itemsParentAttributesobjectCustom attributes for specific grid itemsundefined
childrenReactNodeAdditional children to render in gridundefined

Features

Grid Layout

Control the number of columns and gaps:

{
fieldId: "grid_container",
type: "container",
columns: 3,
gap: 24,
fields: [
// fields will be arranged in 3 columns with 24px gap
]
}

Add custom header and footer components:

const MyHeader = () => <h2>Section Title</h2>;
const MyFooter = () => <p>Section notes</p>;

{
fieldId: "container_with_header_footer",
type: "container",
header: <MyHeader />,
footer: <MyFooter />,
fields: [
// your fields
]
}

Custom Styling

Apply styles at different levels:

{
fieldId: "styled_container",
type: "container",
containerClassName: "bg-gray-100 p-4 rounded-lg",
styles: { border: "1px solid #e2e8f0" },
itemsClassName: "p-2 bg-white",
itemsStyles: { borderRadius: "4px" },
fields: [
// your fields
]
}

Column Spanning

Control how fields span columns using itemsParentAttributes:

{
fieldId: "spanning_container",
type: "container",
columns: 3,
itemsParentAttributes: {
"full_width_field": {
colSpan: 3 // spans all 3 columns
},
"half_width_field": {
colSpan: 2 // spans 2 of 3 columns
}
},
fields: [
{
fieldId: "full_width_field",
// field definition
},
{
fieldId: "half_width_field",
// field definition
}
]
}

Custom HTML Attributes

Add custom attributes to grid items:

{
fieldId: "container_with_attrs",
type: "container",
itemsParentAttributes: {
"special_field": {
"data-testid": "special-field",
"aria-label": "Important field"
}
},
fields: [
{
fieldId: "special_field",
// field definition
}
]
}

Complete Example

import React from "react";

const SectionHeader = () => (
<h2 className="text-xl font-bold mb-4">Personal Information</h2>
);

const SectionFooter = () => (
<p className="text-sm text-gray-500 mt-4">All fields are required</p>
);

{
fieldId: "personal_info_section",
type: "container",
as: "section",
columns: 2,
gap: 20,
containerClassName: "p-6 bg-gray-50 rounded-lg",
header: <SectionHeader />,
footer: <SectionFooter />,
itemsParentAttributes: {
full_name: { colSpan: 2 },
bio: { colSpan: 2 }
},
fields: [
{
fieldId: "full_name",
type: "text",
label: "Full Name",
// field config
},
{
fieldId: "email",
type: "text",
label: "Email",
// field config
},
{
fieldId: "phone",
type: "text",
label: "Phone",
// field config
},
{
fieldId: "bio",
type: "textarea",
label: "Biography",
// field config
}
]
}
Clicky