Text Field

Headless text input primitives for Roblox UI with controlled/uncontrolled state and commit events.

Stable direction
@lattice-ui/text-field

Part of the stable direction toward v1.0.

What It Is For

Use TextField for single-line text entry with label, description, validation message, and commit hooks that stay in one compound tree.

It is the right default when you want field semantics without adopting a pre-skinned input component.

Preview size

Live demo is experimental and may contain bugs.

Install

Global CLI command: lattice add text-field

Monorepo local script

Use your package manager wrapper when running the local lattice command.

pnpm lattice add text-field

npm package: @lattice-ui/text-field

Peer dependencies

  • @rbxts/react
  • @rbxts/react-roblox

Public Exports

  • TextField
  • TextField.Root
  • TextField.Input
  • TextField.Label
  • TextField.Description
  • TextField.Message

State Model

  • TextField.Root manages the current string value plus disabled, readOnly, required, and invalid flags.
  • The package supports controlled and uncontrolled value ownership through value or defaultValue.
  • onValueChange fires on text edits, while onValueCommit fires on commit moments such as focus loss or enter-like confirmation.

Key API

TextField.Root

Use value, defaultValue, onValueChange, onValueCommit, disabled, readOnly, required, and invalid to connect the field to app state.

TextField.Input

Use asChild when the host should be your own TextBox; root-level disabled and read-only rules still flow through.

TextField.Label / Description / Message

Use the companion parts to keep accessibility and field messaging close to the same shared state source.

Composition Patterns

Labeled validated fields

Keep label, input, helper text, and validation message inside one TextField.Root so invalid and read-only state stay coordinated.

Commit-aware settings

Use onValueCommit when the app should treat typing and committed saves differently.

Cautions / Limits

  • Commit callbacks are separate from live change callbacks; do not expect onValueCommit to fire on every keystroke.
  • Use Textarea instead when multi-line input or automatic height growth is part of the field contract.