plushie/widget/text_input

TextInput widget builder (single-line text entry).

Types

Leading or trailing edge for a text input’s icon.

pub type IconSide {
  Left
  Right
}

Constructors

  • Left
  • Right

Option type for text input properties.

pub type Opt {
  Placeholder(String)
  Padding(padding.Padding)
  Width(length.Length)
  Size(Float)
  Font(font.Font)
  LineHeight(line_height.LineHeight)
  AlignX(alignment.Alignment)
  TextDirection(text_direction.TextDirection)
  Icon(TextInputIcon)
  OnSubmit(Bool)
  OnPaste(Bool)
  Secure(Bool)
  InputPurpose(input_purpose.InputPurpose)
  Style(String)
  PlaceholderColor(color.Color)
  SelectionColor(color.Color)
  Required(Bool)
  Validation(validation_state.ValidationState)
  A11y(a11y.A11y)
}

Constructors

pub opaque type TextInput

Glyph displayed inside a text input.

code_point is a single-character string identifying the glyph from font (an icon font when set, the default font otherwise). size and spacing are the pixel size of the glyph and the spacing between the glyph and the text. side selects the leading or trailing edge.

pub type TextInputIcon {
  TextInputIcon(
    code_point: String,
    size: option.Option(Float),
    spacing: option.Option(Float),
    side: option.Option(IconSide),
    font: option.Option(font.Font),
  )
}

Constructors

Values

pub fn a11y(input: TextInput, a: a11y.A11y) -> TextInput

Set accessibility properties for this widget.

pub fn align_x(
  input: TextInput,
  a: alignment.Alignment,
) -> TextInput

Set the horizontal alignment.

pub fn build(input: TextInput) -> node.Node

Build the text input into a renderable Node.

pub fn font(input: TextInput, f: font.Font) -> TextInput

Set the font.

pub fn icon(input: TextInput, i: TextInputIcon) -> TextInput

Set an icon inside the input field.

pub fn input_purpose(
  input: TextInput,
  p: input_purpose.InputPurpose,
) -> TextInput

Set the input purpose hint for IME keyboards.

pub fn line_height(
  input: TextInput,
  lh: line_height.LineHeight,
) -> TextInput

Set the line height.

pub fn new(id: String, value: String) -> TextInput

Create a new text input builder.

pub fn on_paste(input: TextInput, enabled: Bool) -> TextInput

Enable the paste event.

pub fn on_submit(input: TextInput, enabled: Bool) -> TextInput

Enable the submit event.

pub fn padding(input: TextInput, p: padding.Padding) -> TextInput

Set the padding.

pub fn placeholder(input: TextInput, p: String) -> TextInput

Set the placeholder text.

pub fn placeholder_color(
  input: TextInput,
  c: color.Color,
) -> TextInput

Set the placeholder text color.

pub fn required(input: TextInput, r: Bool) -> TextInput

Mark this field as required. Flows into a11y.required.

pub fn secure(input: TextInput, s: Bool) -> TextInput

Set whether input is masked (password mode).

pub fn selection_color(
  input: TextInput,
  c: color.Color,
) -> TextInput

Set the text selection highlight color.

pub fn size(input: TextInput, s: Float) -> TextInput

Set the size.

pub fn style(input: TextInput, s: String) -> TextInput

Set the style.

pub fn text_direction(
  input: TextInput,
  direction: text_direction.TextDirection,
) -> TextInput

Set the text direction used by logical text layout.

Placeholder text uses the same direction hint as the input value.

pub fn validation(
  input: TextInput,
  v: validation_state.ValidationState,
) -> TextInput

Set the form-validation state. Flows into a11y.invalid and a11y.error_message automatically.

pub fn width(input: TextInput, w: length.Length) -> TextInput

Set the width.

pub fn with_opts(input: TextInput, opts: List(Opt)) -> TextInput

Apply a list of options to a text input builder.

Search Document