← Interface components

UI.Screen

luastra/ui
UI.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

layoutthemesemantic

Parameters

ParameterType / valuesDescription
idlowercase path, requiredUnique root-node ID.
documentTitlestring 1…160 bytesDocument or window title; by default the host preserves its own title.
documentDescriptionstring 1…320 bytesOptional page description for web metadata.
documentLanguagelanguage tagOptional document language, for example en or en-US.
childrenUI.Node[]Screen content. app.render returns exactly one Screen.
gapnone | xs | sm | md | lg | xlSpace between children. Group: Layout and surfaces.
paddingnone | xs | sm | md | lg | xl | responsiveAll-side inner spacing; responsive is supported only by padding. Group: Layout and surfaces.
marginnone | xs | sm | md | lg | xlAll-side outer spacing. Group: Layout and surfaces.
paddingX / paddingYnone | xs | sm | md | lg | xlAxis-specific inner spacing. Group: Layout and surfaces.
paddingTop / paddingBottom / paddingStart / paddingEndnone | xs | sm | md | lg | xlLogical side-specific inner spacing. Group: Layout and surfaces.
marginX / marginYnone | xs | sm | md | lg | xlAxis-specific outer spacing. Group: Layout and surfaces.
marginTop / marginBottom / marginStart / marginEndnone | xs | sm | md | lg | xlLogical side-specific outer spacing. Group: Layout and surfaces.
surfaceplain | card | elevated | accentBackground, border, and elevation. Group: Layout and surfaces.
widthfull | content | wideAvailable width, 720 px maximum, or 1180 px maximum. Group: Layout and surfaces.
alignstart | center | end | stretch | betweenCross-axis alignment. Group: Layout and surfaces.
justifystart | center | end | betweenMain-axis alignment. Group: Layout and surfaces.
flowwrap | nowrapFlex wrapping. Group: Layout and surfaces.
responsivebooleanNarrow-screen adaptation. Group: Layout and surfaces.
classNamesafe string ≤ 256 bytesAdditional admitted class tokens. Group: Layout and surfaces.
tonemuted | error | successSemantic text tone. Group: State and semantics.
appearanceprimary | secondary | danger | ghostAction appearance. Group: State and semantics.
variantbody | subheading | heading | titleBody text or h3, h2, and h1 heading semantics. Group: State and semantics.
rolealert | group | statusSupported ARIA role. Group: State and semantics.
labelstringAccessible name. Group: State and semantics.
hiddenbooleanVisibility state. Group: State and semantics.
disabledbooleanDisabled state. Group: State and semantics.
busybooleanaria-busy state. Group: State and semantics.
requiredbooleanRequired input state. Group: State and semantics.
errorIdcomponent idAssociates a visible role=alert. Group: State and semantics.
textColortoken | #RRGGBBLocal or inherited foreground. Group: Text and local colors.
backgroundColortoken | #RRGGBBComponent-box background. Group: Text and local colors.
themeUI.ThemeReusable optional colors; direct fields win. Group: UI.Screen theme.
accentColor#RRGGBBaccent theme color. Group: UI.Screen theme.
dangerColor#RRGGBBdanger theme color. Group: UI.Screen theme.
mutedColor#RRGGBBmuted theme color. Group: UI.Screen theme.
surfaceColor#RRGGBBsurface theme color. Group: UI.Screen theme.
successColor#RRGGBBsuccess theme color. Group: UI.Screen theme.
warningColor#RRGGBBwarning 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 learning

Prerequisites

UI.ThemeUI.Text

Complete inventory

View all pages in Interface components
← Previous: UI.NodeNext: UI.Column →