Skip to content

Text

A text field holds a plain string: a name, a short description, a label. Use rich text when editors need formatting or links.

import {Field} from 'alinea'

Field.text('Summary', {
  help: 'Shown on overview pages',
  multiline: true,
  searchable: true
})

Options

  • multiline: allow line breaks, the field is shown as a text area. Default false.

  • placeholder: a short hint shown while the field is empty.

  • type: the input type, one of 'text' (default), 'email', 'tel' or 'url'. It changes the keyboard on mobile devices and is ignored for multiline fields. It doesn't validate the value, use validate for that.

  • searchable: add the value to the search index, so search queries also match on it. See Search.

  • iconLeft and iconRight: an icon component shown inside the input, before or after the text.

  • autoFocus: focus the input when the entry opens.

  • The common options: help, width, inline, initialValue, required, validate, readOnly, hidden and shared.

Value

The field stores a string and queries return it as is. New entries start with an empty string (''), not undefined, unless you set an initialValue. Line breaks in a multiline field are stored as \n: render them with white-space: pre-line or split on them.

Single-line text fields are shown as a column when an entry's children are listed in the dashboard's overview.