Input field component for Avarda design system.
This module 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.
Input.new "username" {...}
|> Input.withPlaceholder "Enter username"
|> Input.withIsRequired True
|> Input.viewAdd a placeholder to the input.
Chain after new.
Input.new "username" {...}
|> Input.withPlaceholder "Enter username"Mark the input as required.
This adds a * to the label and sets required=true.
Input.new "username" {...}
|> Input.withIsRequired TrueDisable the input. Visually dims and prevents typing.
Input.new "username" {...}
|> Input.withIsDisabled TrueChange the input type (e.g. "text", "password", "email").
Input.new "password" {...}
|> Input.withInputType "password"Limit the maximum number of characters.
Input.new "username" {...}
|> Input.withMaxLength 20Adjust the border radius of the input box.
Input.new "username" {...}
|> Input.withBorderRadius 12Enable autocomplete with a given string like "username" or "off".
Input.new "username" {...}
|> Input.withAutocomplete "username"Attach additional HTML attributes to the underlying <input /> element.
For example name or data-* attributes.
Input.new "username" {...}
|> Input.withAttributes [ Attributes.name "username" ]Add custom CSS styles to the outer wrapper element.
Input.new "username" {...}
|> Input.withAdditionalWrapperStyles [ Css.marginTop (Css.px 16) ]Listen for key presses and map them to messages. Useful for handling Enter/Escape in forms.
Input.new "username" {...}
|> Input.withOnKeyDown [ ( KeyPressUtil.Enter, Submit ) ]Show an error message and mark the input invalid. Replaces any active hint text.
Input.new "username" {...}
|> Input.withMaybeError (Just "This field is required")Add a hint text below the input (shown when there is no error).
Input.new "username" {...}
|> Input.withHint "Must be at least 8 characters"Add a left-side child element, e.g. an icon.
Input.new "username" {...}
|> Input.withLeftChild (Icons.user [])Add a right-side child element, e.g. a clear button.
Input.new "username" {...}
|> Input.withRightChild (Icons.clear [ onClick Clear ])
Create a new input with required fields:
id,value,msg, andlabel.This gives you a base input that you can configure further with
withXfunctions.