Skip to main content

Language Specification

.wraf v1.0 Beta — Formal reference for the wrafjs DSL.

Beta

wrafjs v1.0 is currently in beta. The language spec, control set, and toolchain are stable for experimentation but subject to breaking changes before the final release.


Philosophy

wrafjs is an AI-first language for describing UI wireframes as structured text.

  • Token efficiency — no redundant keywords, no decorative syntax
  • LLM determinism — one way to express each concept, no equivalent alternatives
  • Single-file — one screen per file
  • Structure over behavior — describes what is visible, not what it does

File model

A .wraf file contains exactly one root node of type Screen.

Screen {
width: 1440
height: 900

Navbar { title: "My App" }
Row {
Sidebar { }
Column {
Text { text: "Welcome" variant: title }
}
}
}

Rules:

  • The root node must be Screen.
  • width and height are required on Screen.
  • Multiple root nodes is a parse error.

Grammar

File     ::= Node
Node ::= Identifier Identifier? "{" Body "}"
Body ::= (Property | Node)*
Property ::= Identifier ":" Value
Value ::= String | Number | Boolean | Enum | Percent
TokenSymbolRole
{ }LBrace / RBraceOpen / close node body
:ColonSeparates property name and value
//LineCommentComment to end of line
/* */BlockCommentMulti-line comment

Lexical rules:

  • The language is case-insensitive for node names, labels, and enum values.
  • Whitespace (space, tab, newline) is ignored.
  • Duplicate properties on the same node are an error.
  • A node may have an optional label after its type (Card MetricsPanel { }) — structural metadata, not rendered.

Value types

TypeSyntaxExample
String"text"text: "Save"
Numberbare integerwidth: 360
Booleantrue / falsechecked: true
Enumbare identifiervariant: primary
Percentnumber + %width: 50%
  • Strings always use double quotes. Single quotes are not valid.
  • Enums are never quoted. variant: "primary" is an error.
  • Percent values resolve against the parent's available width or height.

Global properties

Valid on any node.

PropertyTypeDescription
widthnumber | percentNode width
heightnumber | percentNode height
xnumberHorizontal position relative to parent
ynumberVertical position relative to parent
paddingnumberInner inset
gapnumberSpace between children in auto-layout
layouthorizontal | verticalChild flow direction
growModevertical | horizontal | noneSizing behavior when dimensions are not explicit
positionenum (9-point)Floating anchor within parent
hiddenbooleanExclude node from render
disabledbooleanApply disabled appearance

x/y and position are mutually exclusive. If both are declared, x/y takes precedence.


Layout system

Auto-layout

Children without explicit x/y are positioned automatically.

  • layout: vertical (default) — children stacked top to bottom
  • layout: horizontal — children stacked left to right
  • gap — space between consecutive children (default: 8)
  • padding — inset from the container edge (default varies by node type)

GrowMode

ValueWidthHeight
vertical (default)fill — takes all available widthshrink — fits content height
horizontalshrink — fits content widthfill — takes all available height
nonefixed — requires explicit widthfixed — requires explicit height

Position (9-point anchor)

position floats a node at one of 9 named regions inside its parent's content area, without advancing the auto-layout cursor.

LeftCenterRight
Toptoplefttoptopright
Middleleftcenterright
Bottombottomleftbottomcenterbottomright

Requires explicit width and height on the node.

Padding defaults by node

Nodepaddinggap
Screen, Row, Column08
Navbar, Tabbar88
Sidebar124
Card, Form1612
Modal, Drawer2416
ScrollView168
Menu40
Other108

Text system

The variant property sets semantic size and weight on text nodes.

VariantSizeWeight
display36pxbold
title28pxbold
heading22pxbold
subheading18pxbold
body15pxnormal
caption13pxnormal
overline11pxbold
annotation11pxnormal

HTML aliases: h1h6 map to displaycaption.

Text properties: text, variant, weight, align, italic, truncate, color.


Controls reference

Quick reference of all nodes and their intrinsic heights.
For per-control properties and examples, see the sidebar sections.

NodeIntrinsic heightCategory
Screen— (root)Root
Row, ColumnshrinkLayout
CardshrinkLayout
ModalshrinkOverlay
DrawerfillOverlay
ScrollViewshrinkOverlay
Navbar48pxNavigation
SidebarfillNavigation
Tabbar / Tab48px / 40pxNavigation
Breadcrumb32pxNavigation
Pagination36pxNavigation
Menu / MenuItemshrink / 36pxNavigation
Text, Heading36px / 28pxScreen & Sizing
Label24px
Paragraphdynamic
Badge20pxDisplay Controls
Avatarsize-dependentDisplay Controls
Icon20pxDisplay Controls
Imagedeclare explicitlyDisplay Controls
Separator / Divider1pxDisplay Controls
List / ListItemshrink / 36–48pxData Display
Table / TableRowshrink / 40pxData Display
Skeletonlines × 20pxDisplay Controls
Button36px (size-dependent)Input Controls
Input / Password / Search36pxInput Controls
TextArearows × lineH + 16Input Controls
Select / Dropdown36pxInput Controls
Checkbox / Radio24pxInput Controls
Switch / Toggle20pxInput Controls
Slider24pxInput Controls
FileUpload64pxInput Controls
FormshrinkInput Controls
Alert / Toast48pxDisplay Controls
Tooltip32pxDisplay Controls
Progress8pxDisplay Controls
Spinnersize-dependentDisplay Controls

Validation

The validator runs on the AST after parsing and reports:

  • Error — invalid node or property; render should not proceed
  • Warning — valid but suspicious
CodeDescription
E001Root node is not Screen
E002Screen missing width or height
E003Unknown property for node type
E004Wrong value type (e.g., enum with quotes, string without quotes)
E005Duplicate property on the same node
W001Node has no explicit dimensions and no known intrinsic size
W002Button has declared children