Noora.TextInput
(noora v0.76.0)
Copy Markdown
Renders text input and digit input components with customizable types, labels, placeholders, prefixes, suffixes, and event handling.
Example
<.text_input name="username" label="Username" placeholder="Enter username" />
<.text_input type="email" name="email" label="Email" required={true} show_required={true} />
<.text_input type="password" name="password" label="Password" hint="Must be at least 8 characters" />
<.text_input type="search" name="search" placeholder="Search..." />
<.digit_input id="otp-input" characters={6} otp={true} on_complete="verify_otp" />
Summary
Functions
Attributes
id(:string) (required)type(:string) - Defaults to"numeric". Must be one of"alphanumeric","numeric", or"alphabetic".characters(:integer) (required) - The number of characters in the input.placeholder(:string) - Defaults tonil.otp(:boolean) - Defaults tofalse.error(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.on_change(:string) - Event handler for when the input changes. Triggers the event with value{ value: string[], valueAsString: string }Defaults to
nil.on_complete(:string) - Event handler for when the input is complete. Triggers the event with value{ value: string[], valueAsString: string }Defaults to
nil.on_invalid(:string) - Event handler for when the input is invalid. Triggers the event with value{ value: string[], valueAsString: string }Defaults to
nil.Global attributes are accepted.
Attributes
id(:string)field(Phoenix.HTML.FormField) - A Phoenix form field.type(:string) - Type of the input. Defaults to"basic". Must be one of"basic","email","card_number","search", or"password".input_type(:string) - HTML input type when type isbasic. Defaults to"text".label(:string) - Label to be rendered in the input. Defaults tonil.sublabel(:string) - Sublabel to be rendered in the input. Defaults tonil.hint(:string) - Hint text to be rendered below the input. Defaults tonil.hint_variant(:string) - Hint text variant. Defaults to"default".error(:string) - Errors to be rendered below the input. Takes precedence overhint.show_error_message(:boolean) - Whether to show the error message below the input. Defaults totrue.show_prefix(:boolean) - Whether to show the prefix. Defaults totrue.show_suffix(:boolean) - Whether to show the suffix. Defaults totrue.suffix_hint(:string) - Hint text to show as tooltip at the end of the input. Takes precedence over the suffix set bytype. Defaults tonil.name(:string) - The name of the input.value(:string) - The value of the input.placeholder(:string) - Placeholder text to be rendered in the input. Defaults tonil.required(:boolean) - Whether the input is required. Defaults tofalse.show_required(:boolean) - Whether the required indicator is shown. Defaults tofalse.min(:any) - Minimum value for number inputs. Defaults tonil.max(:any) - Maximum value for number inputs. Defaults tonil.step(:any) - Step value for number inputs. Defaults tonil.disabled(:boolean) - Whether the input is disabled. Defaults tofalse.- Global attributes are accepted.
Slots
prefix- Prefix to be rendered in the input. Only shown when type isbasic.suffix- Suffix to be rendered in the input. Takes precedence oversuffix_hint.