datumhue.theme.default_dark() -> ThemeThe built-in dark theme.
In the guide: Theme and density
namespaceTheming7 functions, 1 propertyUI apps only
Read, apply, and reset an app's theme, set its control density, and build theme-tracking colors.
| Field | Type | Access | Description |
|---|---|---|---|
density | theme.Density | read/write | This app's control density: the size of its themed text, spacing, corners and controls. Reading gives the effective value: the app's own, else the nearest ancestor's, else the root's. Writing sets this app's own value, which its descendants inherit unless they set their own; themed widgets resize in place on the next frame and theme.metric returns the new values. At "touch" buttons are at least 48 UI px tall. Text sized in rem keeps its size, and a metric the app's theme sets explicitly applies at every density. The root app starts at "touch" in a browser whose primary pointer is coarse, else at "standard". Writing the value the app already set itself changes nothing. A value outside theme.Density raises. |
datumhue.theme.default_dark() -> ThemeThe built-in dark theme.
In the guide: Theme and density
datumhue.theme.default_light() -> ThemeThe built-in light theme.
In the guide: Theme and density
The theme currently applied to the app — its own pinned theme, or the one it inherits.
In the guide: Theme and density Messages, events and shared state
Apply a theme to the app, pinning it so it no longer follows the inherited theme.
datumhue.theme.pin(datumhue.theme.default_light())
print(datumhue.theme.current().name) --> Everforest Light
local viewer = datumhue.app.spawn({
name = "viewer",
code = "datumhue.ui.root:label({ text = 'Viewer' })",
})
-- A child spawned from `code` can be managed from the next frame.
datumhue.time.wait_frames(1)
datumhue.theme.pin(datumhue.theme.default_dark(), viewer)
print(datumhue.theme.current(viewer).name) --> Everforest DarkIn the guide: Theme and density
datumhue.theme.unpin(target?: App)Drop the app's pinned theme so it follows the inherited theme again (its nearest themed ancestor, else the default).
In the guide: Theme and density
datumhue.theme.token(token: theme.ColorToken) -> ThemedColorA theme color token. Pass it as a UI element color to make that slot follow the active theme and repaint automatically on theme change.
In the guide: Make it interactive Add physics Make it a package
datumhue.theme.metric(token: theme.MetricToken) -> numberThe app's current value for a theme metric token — typography sizes and weights, plus spacing. Use a size token as a font_size value or a weight token as a font_weight value to drive text from the theme.
-- Heights are in UI px.
datumhue.theme.density = "standard"
print(datumhue.theme.metric("button_min_height")) --> 32.0
print(datumhue.theme.metric("font_weight_heading")) --> 600.0
datumhue.theme.density = "touch"
print(datumhue.theme.metric("button_min_height")) --> 48.0In the guide: Theme and density
Used by: datumhue.theme.token
| Value | Description |
|---|---|
"standard" | |
"touch" |
Used by: datumhue.theme.density
Nested in: events.Density
Used by: datumhue.theme.metric