← Interface components

UI.Theme

luastra/ui

UI.Theme is a reusable record of optional screen color overrides. Direct UI.Screen color fields take precedence, while every omitted field inherits Luastra's built-in accessible palette.

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

This type exists during Luau analysis and documents values used by UI constructors or app.render. It is erased from the runtime bundle as a static type.

When to use it

Use UI.Theme to define one reusable palette and pass it to multiple UI.Screen roots. Override only the colors your product owns; omitted fields intentionally retain Luastra's accessible defaults.

Fields or definition

ParameterType / valuesDescription
backgroundColorstring?Default screen and inherited component background color.
textColorstring?Default inherited foreground color for text-bearing components.
accentColorstring?Accent color used by primary controls, outlines, and emphasis tokens.
mutedColorstring?Checked mutedColor field of UI.Theme; its exact admitted type is string?.
surfaceColorstring?Checked surfaceColor field of UI.Theme; its exact admitted type is string?.
successColorstring?Checked successColor field of UI.Theme; its exact admitted type is string?.
warningColorstring?Checked warningColor field of UI.Theme; its exact admitted type is string?.
dangerColorstring?Checked dangerColor field of UI.Theme; its exact admitted type is string?.

Children and layout

This component does not accept arbitrary child nodes; named parameters provide its content.

Accessibility and keyboard

A stable id, logical render-tree order, and visible labels preserve predictable keyboard and screen-reader navigation.

Common mistakes

  • Using a duplicate id or an uppercase path segment.
  • Passing a shared-group parameter that is not listed on this component page.

Returns

UI.Node — a declarative node in the new render tree.

What happens next

A checked annotation that matches the exact exported declaration.

Failures and fixes

If the annotation fails, compare the value with the exact declaration and the producing or consuming function.

Availability

Source API in 0.5.0-alpha; the public installer targets 0.5.0-alpha. Verify host-specific behavior against the selected SDK.

Exact declaration

export type Theme = {
    backgroundColor: string?,
    textColor: string?,
    accentColor: string?,
    mutedColor: string?,
    surfaceColor: string?,
    successColor: string?,
    warningColor: string?,
    dangerColor: string?,
}

Continue learning

Prerequisites

UI.Screen

Companions

UI.Column

Complete inventory

View all pages in Interface components
← Previous: UI.PropertiesNext: UI.Node →