Skip to content

Views

Views define your UI declaratively — no HTML, no CSS classes.

json
{
  "name": "LoginPage",
  "path": "/login",
  "root": {
    "type": "form",
    "fields": [
      { "type": "heading", "label": "Sign in" },
      { "type": "email", "id": "email", "label": "Email" },
      { "type": "password", "id": "password", "label": "Password" },
      { "type": "button", "label": "Login" }
    ]
  }
}

Component types

TypeDescription
formA form container with fields
inputGeneric text input (type="text")
emailEmail input (type="email", built-in validation)
passwordPassword input (type="password", masked text)
buttonButton (type="submit" in forms)
textParagraph of text
heading<h1> heading
containerGeneric <div> with children
flexFlex <div> with layout props
listRenders a list of model instances
tableRenders a table of model instances
cardCard container
selectDropdown select

Binding to models

json
{
  "name": "UserList",
  "path": "/users",
  "root": {
    "type": "list",
    "model": "User"
  }
}

Auto-capitalisation Model refs are automatically capitalised

"model": "users" is treated the same as "model": "Users". :::

Flex layout

The flex type generates a <div style={ { display: 'flex', ... } }>. Supported props:

PropTypeDefault
direction"row" | "row-reverse" | "column" | "column-reverse""row"
alignItems"flex-start" | "flex-end" | "center" | "baseline" | "stretch""stretch"
justifyContent"flex-start" | "flex-end" | "center" | "space-between" | …"flex-start"
gapnumber (px) or string (e.g. "1rem")0
json
{
  "name": "Dashboard",
  "path": "/dashboard",
  "root": {
    "type": "flex",
    "props": {
      "direction": "row",
      "alignItems": "center",
      "justifyContent": "space-between",
      "gap": 16
    },
    "children": [
      { "type": "heading", "label": "Dashboard" },
      { "type": "button", "label": "New" }
    ]
  }
}

Generated output:

tsx
<div
  style={{
    display: 'flex',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    gap: '16px',
  }}
>
  <h1>Dashboard</h1>
  <button type="submit">New</button>
</div>

Generated output

Each view generates a Next.js page component:

  • path: "/login"src/app/login/page.tsx

Released under the Elastic License 2.0.