Renders an input with label and error messages.
A Phoenix.HTML.FormField may be passed as argument,
which is used to retrieve the input name, id, and values.
Otherwise all attributes may be passed explicitly.
This function accepts all HTML input types, considering that:
type="select" to render a <select> tag Phoenix.Component.live_file_input/1 See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input for more information. Unsupported types, such as hidden and radio, are best written directly in your templates.
<.input field={@form[:email]} type="email" /> <.input name="my-input" errors={["oh no!"]} /> # Password input with visibility toggle <.input type="password" name="password" label="Password" /> # The label can be also passed as a custom_label slot (for checkbox, radio, and toggle only) <.input type="checkbox" name="terms"> <:custom_label>Accept <.a href="#">terms and conditions</.a></:custom_label> </.input> # Password input with help text <.input type="password" name="password" label="Password"> <:help>Password must be at least 8 characters long</:help> </.input>
aria-describedby - Links input with toggle button aria-label - Provides context for the toggle button aria-pressed - Indicates toggle state aria-controls - Associates toggle with input field autocomplete="current-password" for secure browser password management <.stack class="gc-full-width" space="lg"> <.input id="textarea-text-plain" label="Label" name="text" type="textarea" value="Standard with text" /> <.input id="textarea-text-overflow" label="Label" name="overflow" type="textarea" value="Standard with text that is long enough to cause an overflow with a scroll bar inside the textarea field. Overflow is handled with a scroll bar when there are lots of words in this type of input. textarea is intended for longer and more complex data, compared to text, which is intended for one line of input. " /> <.input id="textarea-text-placeholder" label="Label" name="placeholder" type="textarea" value="" placeholder="Placeholder text" /> <.input id="textarea-text-required" label="Label" name="required" type="textarea" value="This text is required" required /> <.input id="textarea-text-helper-text" label="Label" name="helper_text" type="textarea" value="" > <:help>Helper text</:help> </.input> <.input id="textarea-text-helper-text-with-icon" label="Label" name="helper_text_with_icon" type="textarea" value="" > <:help icon="book">Helper text with icon</:help> </.input> <.input id="textarea-text-error" label="Label" name="error" type="textarea" value="Some input text" errors={["Error helper text"]} /> <.input disabled id="textarea-text-disabled" label="Disabled" name="disabled" type="textarea" value="Disabled text" > <:help icon="book">Disabled help text</:help> </.input> <.input id="textarea-text-readonly" label="Readonly" name="readonly" type="textarea" value="Readonly text" readonly > <:help icon="book">Readonly help text</:help> </.input> <.input id="textarea-text-with-different-mobile-label" label="Desktop label" name="with_different_mobile_label" type="textarea" value="" mobile_label="Mobile label" /> </.stack>