Browse documentation

Text inputs

Collect free-form text with single-line, multiline, search, password, numeric, and tag controls.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Basic fields

Use a visible label for form fields. TextField supports a placeholder, error, counter, prefix, suffix, and clear action.

Rendered example
Labeled text, multiline, search, password, number, and tag inputs.
Rendered by Zaniah's headless backend.
Ruby
Zaniah::UI::TextField.new("Ruby", label: "Name", clearable: true)
Zaniah::UI::TextArea.new("Several lines", label: "Notes", rows: 3)
Zaniah::UI::SearchInput.new("", placeholder: "Search")

Specialized fields

PasswordInput masks its value. NumberInput enforces optional bounds and increments. TagInput reports a list of tags.

Ruby
Zaniah::UI::PasswordInput.new("", label: "Password")
Zaniah::UI::NumberInput.new(4, min: 0, max: 10)
Zaniah::UI::TagInput.new(%w[ruby ui], placeholder: "Tags")

Validation and token completion

status accepts none, success, warning, and error with an optional message for the tooltip and accessibility description. completion(provider) calls provider.complete(text, caret), which returns nil or Completion.new(range:, items:). Caret and exclusive ranges are UTF-8 byte offsets at grapheme boundaries. Item hashes contain label and optional detail, insert_text, or Matcher ranges.

Typing refreshes a caret-anchored popover. Up/Down choose a candidate; Tab/Enter replace only the supplied token range; Esc closes the popover. request_completion(caret:) opens it explicitly.

Ruby
field = Zaniah::UI::TextField.new("", label: "Filter")
  .status(:warning, message: "Unknown field")
  .completion(provider)

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
TextField(value, placeholder:, label:, prefix:, suffix:, error:, max_length:, clearable:); status(kind, message:), completion(provider)IME, selection, counter, validation, token completion
TextAreaTextField plus rows:multiline/wrapped
SearchInputTextField optionssearch + clear icons
PasswordInputTextField optionsmasked display
NumberInputTextField plus min:, max:, step:; increment, decrementnumeric
TagInput(tags, separator:, ...); on_tags_changebadge list + editor

Accessibility

Labels and errors are associated with their fields. Multiline input exposes a multiline textbox; search exposes a searchbox.

ComponentSemantic role
TextFieldtextbox
TextAreatextbox/multiline
SearchInputsearchbox
PasswordInputtextbox
NumberInputtextbox
TagInputtextbox