UI.Screen
luastra/uiUI.Screen(input: Input): Node
Creates the single root of a rendered interface. It establishes document metadata, the content-width policy, and the inherited color theme that descendants use unless they provide a local override.
Mental model
This is a declarative node: app.render describes it again from current state, while the host matches its stable id to the existing view.
Before you use it
Add luastra/ui to this module's dependencies in luastra.json, then import it with require("luastra/ui"). The project must declare the ui.render capability. app.render must return one UI.Screen root; place this node inside that tree rather than invoking it for a hidden side effect.
How it fits
The constructor validates its fields immediately and returns a UI.Node. After app.render returns, the host reconciles that node by stable id with the current semantic DOM-based interface. Current desktop and mobile hosts package the same web artifact; native adapters are used at capability boundaries.
When to use it
Use UI.Screen exactly once at the root of app.render. Choose it when starting a page or route; use Column, Row, or another container for every nested region.
Shared parameter groups
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| id | lowercase path, required | Unique root-node ID. |
| documentTitle | string 1…160 bytes | Document or window title; by default the host preserves its own title. |
| documentDescription | string 1…320 bytes | Optional page description for web metadata. |
| documentLanguage | language tag | Optional document language, for example en or en-US. |
| children | UI.Node[] | Screen content. app.render returns exactly one Screen. |
| gap | none | xs | sm | md | lg | xl | Space between children. Group: Layout and surfaces. |
| padding | none | xs | sm | md | lg | xl | responsive | All-side inner spacing; responsive is supported only by padding. Group: Layout and surfaces. |
| margin | none | xs | sm | md | lg | xl | All-side outer spacing. Group: Layout and surfaces. |
| paddingX / paddingY | none | xs | sm | md | lg | xl | Axis-specific inner spacing. Group: Layout and surfaces. |
| paddingTop / paddingBottom / paddingStart / paddingEnd | none | xs | sm | md | lg | xl | Logical side-specific inner spacing. Group: Layout and surfaces. |
| marginX / marginY | none | xs | sm | md | lg | xl | Axis-specific outer spacing. Group: Layout and surfaces. |
| marginTop / marginBottom / marginStart / marginEnd | none | xs | sm | md | lg | xl | Logical side-specific outer spacing. Group: Layout and surfaces. |
| surface | plain | card | elevated | accent | Background, border, and elevation. Group: Layout and surfaces. |
| width | full | content | wide | Available width, 720 px maximum, or 1180 px maximum. Group: Layout and surfaces. |
| align | start | center | end | stretch | between | Cross-axis alignment. Group: Layout and surfaces. |
| justify | start | center | end | between | Main-axis alignment. Group: Layout and surfaces. |
| flow | wrap | nowrap | Flex wrapping. Group: Layout and surfaces. |
| responsive | boolean | Narrow-screen adaptation. Group: Layout and surfaces. |
| className | safe string ≤ 256 bytes | Additional admitted class tokens. Group: Layout and surfaces. |
| tone | muted | error | success | Semantic text tone. Group: State and semantics. |
| appearance | primary | secondary | danger | ghost | Action appearance. Group: State and semantics. |
| variant | body | subheading | heading | title | Body text or h3, h2, and h1 heading semantics. Group: State and semantics. |
| role | alert | group | status | Supported ARIA role. Group: State and semantics. |
| label | string | Accessible name. Group: State and semantics. |
| hidden | boolean | Visibility state. Group: State and semantics. |
| disabled | boolean | Disabled state. Group: State and semantics. |
| busy | boolean | aria-busy state. Group: State and semantics. |
| required | boolean | Required input state. Group: State and semantics. |
| errorId | component id | Associates a visible role=alert. Group: State and semantics. |
| textColor | token | #RRGGBB | Local or inherited foreground. Group: Text and local colors. |
| backgroundColor | token | #RRGGBB | Component-box background. Group: Text and local colors. |
| theme | UI.Theme | Reusable optional colors; direct fields win. Group: UI.Screen theme. |
| accentColor | #RRGGBB | accent theme color. Group: UI.Screen theme. |
| dangerColor | #RRGGBB | danger theme color. Group: UI.Screen theme. |
| mutedColor | #RRGGBB | muted theme color. Group: UI.Screen theme. |
| surfaceColor | #RRGGBB | surface theme color. Group: UI.Screen theme. |
| successColor | #RRGGBB | success theme color. Group: UI.Screen theme. |
| warningColor | #RRGGBB | warning theme color. Group: UI.Screen theme. |
Children and layout
Screen content. app.render returns exactly one Screen.
Accessibility and keyboard
Creates the main landmark and owns document language and metadata. Keep one meaningful h1 on each page.
Common mistakes
- Returning multiple roots instead of one UI.Screen.
- Expecting width=content on Screen to produce a full-viewport background.
Returns
Node — a validated declarative UI node that becomes part of the next host-neutral render tree.
What happens next
A validated declarative node appears after it is returned as part of the current render tree.
Failures and fixes
Invalid fields, duplicate IDs, unsupported child combinations, or a missing ui.render capability fail during check, render-tree validation, or host startup.
Availability
Source API in 0.5.0-alpha; the public installer targets 0.5.0-alpha. Verify host-specific behavior against the selected SDK.
Focused example
return UI.Screen {
id = "app/root",
width = "full",
theme = appTheme,
documentTitle = "My Luastra app",
UI.Text { id = "app/title", text = "Hello", variant = "title" },
}Continue with a complete recipe
This checked recipe uses UI.Screen inside complete authored files with the required manifest, test, and run steps.
Open run a delayed action recipe