Layout Components

Container, Flex, Grid, Spacer, Divider, Section

Layout Components

Layout components structure your UI with containers, flexbox, grid, and spacing.

Container

A basic block-level wrapper.

json
{
  "type": "Container",
  "className": "p-6 max-w-4xl mx-auto",
  "children": [
    { "type": "Heading", "text": "Welcome" },
    { "type": "Text", "content": "Content here" }
  ]
}

Properties

PropertyTypeDefaultDescription
childrenarray[]Child components
classNamestring-CSS classes
asstringdivHTML element

Examples

Page wrapper:

json
{
  "type": "Container",
  "className": "min-h-screen p-6 bg-gray-50",
  "children": [...]
}

Card-like container:

json
{
  "type": "Container",
  "className": "bg-white rounded-lg shadow-md p-4",
  "children": [...]
}

Flex

Flexbox layout container.

json
{
  "type": "Flex",
  "direction": "row",
  "justify": "between",
  "align": "center",
  "gap": "1rem",
  "children": [
    { "type": "Text", "content": "Left" },
    { "type": "Button", "label": "Right" }
  ]
}

Properties

PropertyTypeDefaultDescription
childrenarray[]Child components
directionrow | column | row-reverse | column-reverserowFlex direction
justifystart | end | center | between | around | evenlystartMain axis alignment
alignstart | end | center | stretch | baselinestretchCross axis alignment
wrapnowrap | wrap | wrap-reversenowrapFlex wrap
gapstring-Gap between items
classNamestring-CSS classes

Examples

Header with actions:

json
{
  "type": "Flex",
  "justify": "between",
  "align": "center",
  "children": [
    { "type": "Heading", "text": "Dashboard", "level": 1 },
    {
      "type": "Flex",
      "gap": "0.5rem",
      "children": [
        { "type": "Button", "label": "Export", "variant": "outline" },
        { "type": "Button", "label": "Create New" }
      ]
    }
  ]
}

Vertical stack:

json
{
  "type": "Flex",
  "direction": "column",
  "gap": "1rem",
  "children": [
    { "type": "Field", "name": "name", "label": "Name" },
    { "type": "Field", "name": "email", "label": "Email" },
    { "type": "Button", "label": "Submit" }
  ]
}

Centered content:

json
{
  "type": "Flex",
  "justify": "center",
  "align": "center",
  "className": "min-h-[400px]",
  "children": [
    { "type": "Text", "content": "Centered" }
  ]
}

Grid

CSS Grid layout.

json
{
  "type": "Grid",
  "columns": 3,
  "gap": "1rem",
  "children": [
    { "type": "Card", "title": "Card 1" },
    { "type": "Card", "title": "Card 2" },
    { "type": "Card", "title": "Card 3" }
  ]
}

Properties

PropertyTypeDefaultDescription
childrenarray[]Child components
columnsnumber | object1Number of columns
rowsnumber-Number of rows
gapstring-Gap between cells
rowGapstring-Row gap
columnGapstring-Column gap
classNamestring-CSS classes

Responsive Columns

Use an object for responsive breakpoints:

json
{
  "type": "Grid",
  "columns": {
    "sm": 1,
    "md": 2,
    "lg": 3,
    "xl": 4
  },
  "gap": "1.5rem",
  "children": [...]
}

Examples

Dashboard stats:

json
{
  "type": "Grid",
  "columns": { "sm": 1, "md": 2, "lg": 4 },
  "gap": "1rem",
  "children": [
    { "type": "StatCard", "title": "Users", "value": "{{state.stats.users}}" },
    { "type": "StatCard", "title": "Revenue", "value": "${{state.stats.revenue}}" },
    { "type": "StatCard", "title": "Orders", "value": "{{state.stats.orders}}" },
    { "type": "StatCard", "title": "Growth", "value": "{{state.stats.growth}}%" }
  ]
}

Feature grid:

json
{
  "type": "Grid",
  "columns": { "sm": 1, "lg": 2 },
  "gap": "2rem",
  "children": [
    {
      "type": "Card",
      "title": "Recent Activity",
      "content": { "type": "List", "dataSource": "state:recentActivity" }
    },
    {
      "type": "Card",
      "title": "Performance",
      "content": { "type": "Chart", "chartType": "line" }
    }
  ]
}

Spacer

Adds vertical space between elements.

json
{
  "type": "Spacer",
  "size": "lg"
}

Properties

PropertyTypeDefaultDescription
sizexs | sm | md | lg | xlmdSpace amount
classNamestring-CSS classes

Size Reference

SizeValue
xs0.5rem (8px)
sm1rem (16px)
md1.5rem (24px)
lg2rem (32px)
xl3rem (48px)

Example

json
{
  "type": "Container",
  "children": [
    { "type": "Heading", "text": "Section 1" },
    { "type": "Text", "content": "Content..." },
    { "type": "Spacer", "size": "xl" },
    { "type": "Heading", "text": "Section 2" },
    { "type": "Text", "content": "More content..." }
  ]
}

Divider

A horizontal or vertical separator line.

json
{
  "type": "Divider"
}

Properties

PropertyTypeDefaultDescription
orientationhorizontal | verticalhorizontalDirection
classNamestring-CSS classes

Examples

Horizontal divider:

json
{
  "type": "Container",
  "children": [
    { "type": "Text", "content": "Above" },
    { "type": "Divider" },
    { "type": "Text", "content": "Below" }
  ]
}

Vertical divider:

json
{
  "type": "Flex",
  "align": "center",
  "gap": "1rem",
  "children": [
    { "type": "Text", "content": "Left" },
    { "type": "Divider", "orientation": "vertical", "className": "h-6" },
    { "type": "Text", "content": "Right" }
  ]
}

Styled divider:

json
{
  "type": "Divider",
  "className": "my-8 border-blue-500"
}

Section

Semantic section wrapper with optional title.

json
{
  "type": "Section",
  "title": "User Settings",
  "children": [
    { "type": "Form", "..." }
  ]
}

Properties

PropertyTypeDefaultDescription
childrenarray[]Child components
titlestring-Section heading
descriptionstring-Section description
ariaLabelstring-Accessibility label
classNamestring-CSS classes

Examples

Settings section:

json
{
  "type": "Section",
  "title": "Notifications",
  "description": "Configure how you receive notifications",
  "className": "mb-8",
  "children": [
    {
      "type": "Form",
      "fields": [
        { "name": "email", "fieldType": "checkbox", "label": "Email notifications" },
        { "name": "push", "fieldType": "checkbox", "label": "Push notifications" }
      ]
    }
  ]
}

Page with sections:

json
{
  "type": "Container",
  "className": "space-y-8",
  "children": [
    {
      "type": "Section",
      "title": "Profile",
      "children": [{ "...profile content..." }]
    },
    {
      "type": "Section",
      "title": "Security",
      "children": [{ "...security content..." }]
    },
    {
      "type": "Section",
      "title": "Preferences",
      "children": [{ "...preferences content..." }]
    }
  ]
}

Layout Patterns

Page Layout

json
{
  "type": "Container",
  "className": "min-h-screen",
  "children": [
    {
      "type": "Container",
      "className": "max-w-7xl mx-auto p-6",
      "children": [
        { "type": "PageHeader", "title": "Dashboard" },
        { "type": "Spacer", "size": "lg" },
        {
          "type": "Grid",
          "columns": { "lg": 3 },
          "gap": "1rem",
          "children": [{ "...content..." }]
        }
      ]
    }
  ]
}

Two-Column Layout

json
{
  "type": "Grid",
  "columns": { "md": 2 },
  "gap": "2rem",
  "children": [
    {
      "type": "Container",
      "children": [{ "...main content..." }]
    },
    {
      "type": "Container",
      "className": "lg:sticky lg:top-6",
      "children": [{ "...sidebar..." }]
    }
  ]
}

Centered Card

json
{
  "type": "Flex",
  "justify": "center",
  "align": "center",
  "className": "min-h-screen p-6",
  "children": [
    {
      "type": "Card",
      "className": "w-full max-w-md",
      "title": "Sign In",
      "content": { "type": "Form", "..." }
    }
  ]
}