Styles of Lumen elements. The style prop of an element is a table, and this library resolves it into the form the panels and the layout engine read: lengths are scaled to the screen resolution with math.scale (set scale = false in the style to keep them as they are), shorthands are expanded, and colors and fonts may name values of the active theme.

<view style={{ direction = 'row', gap = 8, padding = { 4, 12 }, background = 'main_dark' }}>
  <text style={{ flex = 1, font = 'text_normal', color = 'text' }}>Name</text>
  <text style={{ width = '25%', text_align = 'right', color = '#ff8800' }}>42</text>
</view>

The properties are:

  • Size: width, height, min_width, min_height, max_width, max_height. A number is a length, a string such as '50%' is a share of the parent's inner size, 'auto' (or nothing) lets the content decide.
  • Flex item: flex (Number how much of the free space of the parent the element takes, 0 by default), margin (a length for all sides, { vertical, horizontal }, { top, right, bottom, left } or { top = n, left = n, ... }) along with margin_top, margin_right, margin_bottom and margin_left, and align_self ('start', 'center', 'end' or 'stretch', which overrides the parent's align for this element).
  • Flex container (view, scroll): direction ('column' by default or 'row'), justify ('start', 'center', 'end', 'space_between', 'space_around' or 'space_evenly'), align ('stretch' by default, 'start', 'center' or 'end'), gap (length between the children), wrap (Boolean start a new line when the children do not fit) and padding (like margin, with padding_top and the others).
  • Looks: background (Color), border (Color), border_width (1 by default), radius (rounded corners), alpha (0 to 255, the whole panel), cursor (such as 'hand').
  • Text (text, button): font, font_size (derives a copy of the font at that size), color, text_align ('left', 'center' or 'right'), vertical_align ('top', 'center' or 'bottom'), wrap_text (Boolean wrap long lines, true by default).
  • Button: hover_background, active_background, disabled_color.
  • Position: x and y place an element that is mounted into a panel that is not a Lumen container at that spot (the layout engine positions everything else).

A color may be a Color, the name of a color of the active theme (Theme.get_color) or a hex string ('#rgb', '#rrggbb' or '#rrggbbaa'). A font may be the name of a font of the active theme (Theme.get_font) or the name of a font created with surface.CreateFont.

Summary

Functions

Keeps a length between the minimum and the maximum of a resolved style.
Resolves a color: a Color, the name of a theme color or a hex string.
Resolves a font: the name of a theme font or the name of a created font, at a size.
Turns a resolved size into pixels.
Resolves a style table into the form the panels and the layout engine read: scaled lengths, expanded boxes, Colors and font names.

Functions

Lumen.Style.clamp(value, min, max, available)

client packages/lumen/lib/cl_style.lua:277

Keeps a length between the minimum and the maximum of a resolved style.

Parameters

  • value Number
  • min Number/Map resolved minimum, or nil
  • max Number/Map resolved maximum, or nil
  • available Number size that percentages refer to, nil if unknown

Returns

  • Number

Lumen.Style.color(value)

client packages/lumen/lib/cl_style.lua:150

Resolves a color: a Color, the name of a theme color or a hex string.

Parameters

  • value Any

Returns

  • Color, or nil if there is no such color

Lumen.Style.font(value, size)

client packages/lumen/lib/cl_style.lua:172

Resolves a font: the name of a theme font or the name of a created font, at a size.

Parameters

  • value String
  • size Number optional, defaults to nil size to derive a copy of the font at, already scaled

Returns

  • String name of the font, or nil if none was given

Lumen.Style.length(size, available)

client packages/lumen/lib/cl_style.lua:261

Turns a resolved size into pixels.

Parameters

  • size Number/Map a resolved size: a length or { percent = n }
  • available Number the size of the parent that percentages refer to, nil if unknown

Returns

  • Number pixels, or nil if the size is auto or a percentage of an unknown size

Lumen.Style.resolve(style, defaults)

client packages/lumen/lib/cl_style.lua:210

Resolves a style table into the form the panels and the layout engine read: scaled lengths, expanded boxes, Colors and font names. Defaults fill in what the style does not set.

Parameters

  • style Map the style as written, or nil
  • defaults Map optional, defaults to nil the default style of the element, in the same form as style

Returns

  • Map the resolved style

Defined in