text_input

Text Input

Component defintion

def text_input(assigns) do
  ~H"""
  <.input
    type="text"
    field={@field}
    class={[
      "input input-bordered w-full max-w-xs",
      @field.errors != [] && "input-error text-error"
    ]}
    {@rest}
  />
  """
end

Example usage

Default
<.text_input field={@form[:name]} placeholder="Name"/>
<.error field={@form[:name]}/>
Error
<label class="form-control w-full max-w-xs">
  <.text_input field={@form[:email]} placeholder="Name"/>
  <.error field={@form[:email]}/>
</label>