TECHNOLOGY

Ito, a new Lua library, lets developers build terminal interfaces in a SwiftUI-like style

Ito, a declarative UI library for Lua that is heavily inspired by SwiftUI. It includes a browser-based workshop with a live preview.

Terminal window showing a rounded-border shop screen for a notebook with quantity buttons and a gift-wrap checkboxTECHNOLOGY

Image: Ito

Ito is a new library for building terminal user interfaces in Lua. The project describes itself as a declarative UI library, heavily inspired by SwiftUI.

Declarative means you describe what the screen should look like, and the library handles drawing it. You don't give it step-by-step drawing instructions. SwiftUI is Apple's framework for building app interfaces, and Ito borrows its overall style.

To get started, you load the library with require("ito") and return a function that builds a view. For values that change, such as a counter or a checkbox, you use ito.state(value). The project's documentation says views are composed from pieces like VStack, HStack and Text, plus the controls listed in a file called ito.md. A VStack stacks items vertically, and an HStack lines them up horizontally.

Styling is done by chaining methods onto a view. The examples use :spacing(1), :padding(2), :grow(), :bold() and :dim() to arrange and style things.

The project's example is a small shop screen for a notebook called "Field Notes" from "The Small Goods Shop". It has a heading, a price of $18, and plus and minus buttons that change the quantity between 1 and 9. There is also a checkbox to add gift wrap for $3, and an "Add to bag" button that shows the running total. The whole thing sits inside a rounded border.

The buttons in the example also carry accessibility labels, such as "Fewer notebooks" and "More notebooks".

The project also points to a way to try it in the browser. It is described as an interactive workshop with a live preview.

Sources and further readingito playground · uji ↗
ABOUT THE DESK

Harsh DV

IntraGoals reports on important changes in technology and work. We check each story for clear writing, trusted sources and useful information before it is published.

KEEP READING

Latest from IntraGoals.

All latest stories ↗