This component provides a styled input with support for floating labels, hints, error messages, and optional left/right children. It uses the builder pattern:
new to create a base input.withPlaceholder or withIsRequired.view to render it.Render the configured input as HTML.
Always call this after you've built up the input with new and chained settings.
AvardaUi.Input.new "username" {...}
|> AvardaUi.Input.withPlaceholder "Enter username"
|> AvardaUi.Input.withIsRequired True
|> AvardaUi.Input.viewAdd a placeholder to the input.
Mark the input as required.
This adds a * to the label and sets required=true.
Disable the input. Visually dims and prevents typing.
Change the input type (e.g. "text", "password", "email").
Limit the maximum number of characters.
Adjust the border radius of the input box.
Enable autocomplete with a given string like "username". It is set to "off" by default.
Attach additional HTML attributes to the underlying <input /> element.
For example name or data-* attributes.
Listen for key presses and map them to messages.
It uses the KeyboardKey type from AvardaUi.Util.KeyPress module.
AvardaUi.Input.new "username" {...}
|> AvardaUi.Input.withOnKeyDown [ ( KeyPressUtil.Enter, HandleSubmit ) ]Show an error message and mark the input invalid. Replaces any active hint text.
Add a hint text below the input.
Add a left-side child element, e.g. an icon.
Add a right-side child element, e.g. a clear button.
Create a new input with required fields:
id,value,msg, andlabel.This gives you a base input that you can configure further with
withXfunctions.