bricks_create_classes_batch
Overview
Creates multiple global CSS classes in a single API call, which is significantly faster than creating them individually. Supports up to 50 classes per batch, each with full CSS settings, optional selectors (hover, focus, pseudo-elements), and category assignment.
This is the preferred tool during Phase 2 (Design System Setup) when establishing the full set of utility, typography, button, card, and layout classes. One batch call replaces dozens of individual bricks_create_global_class calls.
Key Features
When to Use
When setting up typography scale classes (text-sm, text-base, text-lg, text-xl, etc.)
When creating a complete button system (btn-primary, btn-secondary, btn-ghost, btn-sm, btn-lg)
When building card utility classes (card, card-hover, card-horizontal, card-content)
Any time you need to create 3 or more classes at once
When NOT to Use
When updating existing classes — use bricks_update_global_class
When you need complex per-class error handling — individual calls give more granular feedback
Parameters
classesarrayREQUIREDCode Examples
Create typography and button classes in one batch
Sets up the core design system classes across multiple categories in a single API call. Includes responsive typography and hover selectors.
// Create a complete typography + button class set
bricks_create_classes_batch({
classes: [
{
name: "text-sm",
category: "Typography",
settings: { "_typography": { "font-size": "13px", "line-height": "1.5" } }
},
{
name: "text-base",
category: "Typography",
settings: { "_typography": { "font-size": "16px", "line-height": "1.6" } }
},
{
name: "text-lg",
category: "Typography",
settings: { "_typography": { "font-size": "20px", "line-height": "1.5" } }
},
{
name: "heading-section",
category: "Typography",
settings: {
"_typography": {
"font-size": "36px",
"font-weight": "600",
"line-height": "1.3"
},
"_typography:mobile_portrait": { "font-size": "28px" }
}
},
{
name: "btn-primary",
category: "Buttons",
settings: {
"_background": { "color": { "raw": "var(--bricks-color-primary)" } },
"_typography": { "color": { "hex": "#ffffff" }, "font-weight": "600" },
"_padding": { "top": "14", "right": "28", "bottom": "14", "left": "28" },
"_border": { "radius": { "top": "8", "right": "8", "bottom": "8", "left": "8" } },
"_cssTransition": "all 0.3s ease"
},
selectors: [
{ selector: "&:hover", settings: { "_opacity": "0.9" } }
]
},
{
name: "btn-secondary",
category: "Buttons",
settings: {
"_background": { "color": "transparent" },
"_typography": { "color": { "raw": "var(--bricks-color-primary)" }, "font-weight": "600" },
"_padding": { "top": "14", "right": "28", "bottom": "14", "left": "28" },
"_border": {
"width": { "top": "2", "right": "2", "bottom": "2", "left": "2" },
"style": "solid",
"color": { "raw": "var(--bricks-color-primary)" },
"radius": { "top": "8", "right": "8", "bottom": "8", "left": "8" }
},
"_cssTransition": "all 0.3s ease"
}
}
]
}){
"created": [
{ "id": "a1b2c3", "name": "text-sm", "category": "Typography" },
{ "id": "d4e5f6", "name": "text-base", "category": "Typography" },
{ "id": "g7h8i9", "name": "text-lg", "category": "Typography" },
{ "id": "j0k1l2", "name": "heading-section", "category": "Typography" },
{ "id": "m3n4o5", "name": "btn-primary", "category": "Buttons" },
{ "id": "p6q7r8", "name": "btn-secondary", "category": "Buttons" }
],
"errors": [],
"message": "6/6 classes created successfully."
}Common Mistakes
bricks_create_classes_batch({
classes: [
{ name: "my-class", settings: { "_typography": { "font-size": "16px" } } }
]
})bricks_create_global_class({
name: "my-class",
settings: { "_typography": { "font-size": "16px" } }
}){ name: "btn-primary", settings: {
"_background": { "color": { "hex": "#4361ee" } },
"_padding": { "top": "14", "right": "28", "bottom": "14", "left": "28" }
}}{ name: "btn-primary", settings: {
"_background": { "color": { "raw": "var(--bricks-color-primary)" } },
"_padding": { "top": "14", "right": "28", "bottom": "14", "left": "28" }
}}// Create classes and immediately start building pages
bricks_create_classes_batch({ classes: [...] })
bricks_add_section({ ... }) // Classes may not be compiled yet!// Create classes, regenerate, then build
bricks_create_classes_batch({ classes: [...] })
bricks_regenerate_assets()
bricks_add_section({ ... })Tips & Warnings
Performance: One batch call with 20 classes is ~10x faster than 20 individual bricks_create_global_class calls. Always prefer batch for Phase 2 design system setup.
Limit: Maximum 50 classes per batch. For larger class libraries, split into multiple batch calls.
Error handling: The response includes both created and errors arrays, so you can see which classes succeeded and which failed (e.g., duplicate names).
Recommended batch groupings: Typography classes (6-8), Button classes (4-6), Card classes (3-5), Layout utilities (3-5), Spacing utilities (3-5).