DatumHueEnterprise v0.0.24datumhue.com
Contents

Lay out a screen

Build a screen from panels, labels and buttons, arrange them in flex rows and columns, and follow the space your app is given.

Build on a parent

Every widget is a method on the element it goes in. ui.root:panel builds at the top of your app, UiElement:button builds inside another element, and each returns the new UiElement. A panel stacks its children in a column; give it flex_direction = "row" to put them side by side.

The program below lays out a small library: a header, a list beside a shelf of books, and a status line.

library.lualua
local ui = datumhue.ui
local token = datumhue.theme.token

local page = ui.root:panel({
    width = "100%",
    height = "100%",
    gap = 12,
})

local header = page:panel({
    flex_direction = "row",
    align_items = "center",
    padding = 0,
})
header:label({ text = "Library", font_size = "1.5rem", flex_grow = 1 })
local add = header:button({ text = "Add book" })
add.color = token("accent_primary")
add:set_text_color(token("panel_background"))

local body = page:panel({
    flex_direction = "row",
    flex_grow = 1,
    gap = 12,
    padding = 0,
})
body:list({
    items = { "Reading", "Finished", "Wishlist" },
    width = 160,
})
local shelf = body:panel({
    flex_direction = "row",
    flex_wrap = "wrap",
    align_content = "start",
    flex_grow = 1,
    gap = 12,
    color = token("surface_sunken"),
})

local status = page:label({ color = token("text_secondary") })

local function add_book(title, cover)
    local card = shelf:button({
        accessible_label = title,
        flex_direction = "column",
        width = 140,
        gap = 8,
        on_click = function()
            status.text = "Opened " .. title
        end,
    })
    card:panel({ width = "100%", height = 80, color = token(cover) })
    card:label({ text = title })
end

add_book("Dune", "accent_data")
add_book("Emma", "accent_secondary")
add_book("Ulysses", "info")
add:on_click(function()
    add_book("New book", "accent_tertiary")
end)

ui.root:on_resize(function(size)
    if size then
        status.text = string.format("%.0f x %.0f", size.x, size.y)
    end
end)

In this example: datumhue.ui datumhue.theme.token datumhue.ui.root UiElement:panel UiElement:label UiElement:button UiElement.color UiElement:set_text_color UiElement:list UiElement.text UiElement:on_click UiElement:on_resize

  • page fills the window. The body's flex_grow = 1 gives it the height the header and the status line leave.
  • The shelf wraps its books onto a new row when it runs out of width; align_content = "start" keeps the rows at the top.
  • Each book is a card (below): a button with no text, holding a cover and a title. Add book builds another one.
  • Every color is a theme token, so the screen follows the theme.
  • ui.root:on_resize writes your app's size into the status line each time it changes.

Rows, columns and space

ToSet
put children side by sideflex_direction = "row" on the parent
give one child the space the others leaveflex_grow = 1 on it
space children apartgap on the parent
keep content off the edgespadding
line children up across a row or columnalign_items on the parent
spread children along itjustify_content on the parent
wrap children onto new rowsflex_wrap = "wrap" on the parent
place children in columnsdisplay = "grid" and grid_template_columns on the parent

Panels and buttons start with the theme's padding and rounded corners. Pass padding = 0 or border_radius = 0 to drop them; the header and the body above drop their padding.

A size is a number of UI px, or a string with a unit such as "50%" of the parent; Coordinates and units lists the units. padding, margin and border take any of these:

  • one value, for all four sides;
  • a table naming the sides you set, such as { left = 8, top = 4 }, the rest 0;
  • a CSS shorthand array, from { a } to { a, b, c, d }.

To center an element with its margins, name both sides: margin = { left = "auto", right = "auto" }.

Place children in columns

A panel with display = "grid" places its children in the columns grid_template_columns gives, filling them a row at a time. A count gives that many equal columns. A list gives each column its own width: a size, "max_content" for a column as wide as its widest child, or "1fr" for a share of the width the other columns leave.

grid.lualua
local ui = datumhue.ui
local token = datumhue.theme.token

local page = ui.root:panel({
    width = "100%",
    height = "100%",
    gap = 12,
})

local shelf = page:panel({
    display = "grid",
    grid_template_columns = 3,
    gap = 8,
    padding = 0,
})
for _, cover in ipairs({
    "accent_data",
    "accent_secondary",
    "info",
    "accent_primary",
}) do
    shelf:panel({ height = 60, color = token(cover) })
end

local form = page:panel({
    display = "grid",
    grid_template_columns = { "max_content", "1fr" },
    align_items = "center",
    gap = 8,
    padding = 0,
})
form:label({ text = "Title" })
form:text_input({ value = "Dune" })
form:label({ text = "First published" })
form:text_input({ value = "1965" })

In this example: datumhue.ui datumhue.theme.token datumhue.ui.root UiElement:panel UiElement:label UiElement:text_input

  • The fourth cover starts a second row and keeps its column's width.
  • The labels' column is as wide as the longer label, and the fields take the rest of the row.
  • A shared column never narrows below 0 px, so content wider than its column runs past it.
  • To change the count as the width changes, pass a new one to UiElement:update from UiElement:on_resize.

Labels that wrap

A label wraps its text between words, and breaks a word too wide for its box between two characters. In a row, a label is never narrower than its widest word unless you let it be: give it min_width = 0, max_width = "100%" or a width. Its min_width and min_height only keep it from shrinking; it always grows to fit its text.

Cards

A button made without text is a card. The panels, labels, images and code you build in it are its content, and the whole card is one focus stop and one target, so a tap anywhere on it presses it. Give it an accessible_label, since it has no text to be named by. Show code there with UiElement:code, which draws it as a book page draws a listing; a text field cannot go inside a card.

Nothing interactive goes inside a card: no buttons, links or tables, and no book page with links or widgets. Place a card's quick actions beside it. Its content takes no presses of its own, so set press, drag and context handlers on the card itself.

Show code as typed

The font DatumHue draws text in joins some signs into one shape: >= draws as one sign, == as one long bar and != as a crossed equals sign. Where someone reads code to type it, set ligatures = false on the element that shows it, and each character draws as typed. Code elements, text fields and labels take it, and Book:mount takes it for a whole page.

Make a button stand out

Give it a fill and a label color from the theme, as Add book has, so both follow the theme. Assign UiElement.color a token such as theme.token("accent_primary"), and pass UiElement:set_text_color a token that reads on that fill. The fill stays through hover and press, which lay a faint wash of the label color over it, and a disabled button still shows the theme's disabled colors.

Follow the space you are given

Layout runs after your code, once a frame. UiElement.bounds reads the box an element was given, in UI px from the top-left of your app's content area. A size you set reads back from the next frame, and bounds is nil before the first layout and while the element or a parent has display = "none".

React to changes instead of reading bounds every frame:

  • UiElement:on_resize runs each time an element's size changes. On ui.root it follows your whole app as the window, the zoom or a window manager resizes it.
  • UiElement:on_visibility runs when an element's own visible changes, whoever changed it: your code, or a popover closing on a press outside it or on Back.

See also

Reference used on this page: datumhue.ui datumhue.theme.token datumhue.ui.root UiElement:panel UiElement:label UiElement:button UiElement.color UiElement:set_text_color UiElement:list UiElement.text UiElement:on_click UiElement:on_resize UiElement:text_input UiElement:update UiElement:code Book:mount UiElement.bounds UiElement:on_visibility

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page