Input
The unified form field component. Renders inputs with optional label, description, and error handling. Integrates with Phoenix forms.
With Label
Add a label using the
label
attribute. The label renders directly above the input.
With Description
Add helper text using the
description
attribute. It renders between the label and the input, and is linked via
aria-describedby
for accessibility.
With Errors
Pass error messages via the
errors
attribute. The input automatically gets
aria-invalid="true"
and errors display below.
Password must be at least 8 characters.
Input Types
The input component supports all standard HTML input types.
Checkbox
Use
type="checkbox"
for boolean inputs. The label renders inline next to the checkbox.
Switch
Use
type="switch"
for toggle inputs. Renders with
role="switch"
for accessibility.
Receive email notifications for updates.
Select
Use
type="select"
for native select dropdowns.
Textarea
Use
type="textarea"
for multi-line text input.
Disabled
Use the disabled attribute to prevent interaction.
With Form
The input component integrates seamlessly with Phoenix forms using the
field
attribute. Errors from the changeset are displayed automatically after interaction.
<.form for={@form} phx-change="validate" phx-submit="save">
<.input field={@form[:email]} type="email" label="Email" />
<.input field={@form[:password]} type="password" label="Password" />
<.input
field={@form[:bio]}
type="textarea"
label="Bio"
description="Tell us about yourself."
/>
<.button type="submit">Submit</.button>
</.form>
Complete Example
A live form with changeset-based validation. Errors appear only after you interact with each field. Try tabbing through, or hit Register with empty fields.