Log inGet started
Package

input.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

input

Text input widget. Single-line by default; pass multiline = true for a textarea. The code-editor variant (syntax-highlight, line numbers, folding) lives in zui.widget.codeEditor — same underlying widget kind, more defaults, plus the Luau highlighter producing segments.

Exports

  • input(id: string, value: string?, opts: InputOpts?) -> WidgetNode — module returns the builder function directly.

Options forwarded to the node's props:

  • placeholder: string?
  • onChange: string? — callback id
  • submitOnEnter: boolean?
  • multiline: boolean?
  • password: boolean?
  • codeEditor: boolean?
  • number: ("whole" | "decimal")? — the field takes a number: an on-screen keyboard shown for it (Android's number keyboard, a browser's inputmode) is laid out for digits, with a decimal separator for "decimal". onChange reports the text as typed.
  • signed: boolean? — with number, the number may be negative: the keyboard offers a minus sign.
  • segments: { Segment }? — pre-highlighted layout segments
  • foldLanguage: string? — opt into the Rust fold detector ("lua" etc.)
  • lineNumbers: boolean?, folding: boolean?
  • props, classes, style — standard widget plumbing.

Usage

local Z = require("@builtin::modules.zui")

Z.input("name", state.name, {
    placeholder = "Your name",
    onChange    = "name:edit",
})

-- Multiline:
Z.input("notes", state.notes, { multiline = true })

-- A price, typed on a phone's number keyboard:
Z.input("price", state.price, { number = "decimal", onChange = "price:edit" })

Notes

  • When props.segments is supplied, the renderer builds the LayoutJob from segments instead of the plain text string — but text is still set, so the underlying value continues to work for callbacks.
  • For syntax-highlighted code editing, prefer Z.codeEditor, which bundles foldLanguage, lineNumbers, folding, and a default highlighter call.
  • Stateless — the parent owns the buffer; this widget only renders.