UI.TextStyle
luastra/uiUI.TextStyle declares a packaged font, fallback family, bounded text size, weight and line height. Constructors translate it into validated style classes without arbitrary CSS or changes to the VM protocol.
Mental model
A checked style record consumed by a text component on each render.
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 textStyle on Text, Button, Link, TextInput, Code or CodeBlock. Font references come from Assets.font; size is an integer 8–128 in sixteenths of a rem, weight is 100–900 in steps of 100, and lineHeight is 1–3 in steps of 0.01. Fallback is sans, serif or mono. Styles are local to the text component; omitted fields keep existing defaults.
Fields or definition
| Parameter | Type / values | Description |
|---|---|---|
| font | Assets.Font? | Checked font field of UI.TextStyle; its exact admitted type is Assets.Font?. |
| size | number? | Checked size field of UI.TextStyle; its exact admitted type is number?. |
| weight | number? | Checked weight field of UI.TextStyle; its exact admitted type is number?. |
| lineHeight | number? | Checked lineHeight field of UI.TextStyle; its exact admitted type is number?. |
| fallback | ("sans" | "serif" | "mono")? | Checked fallback field of UI.TextStyle; its exact admitted type is ("sans" | "serif" | "mono")?. |
Children and layout
This is a style value, not a UI node; it has no children or id.
Accessibility and keyboard
Prefer readable sizes and line heights, and keep fallback text readable while a font loads.
Common mistakes
- Using an undeclared font asset.
- Assuming a Latin-only font covers every script.
- Expecting a font-ready event or container-level inheritance.
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 TextStyle = {
font: Assets.Font?,
size: number?,
weight: number?,
lineHeight: number?,
fallback: ("sans" | "serif" | "mono")?,
}