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 <form class="gc-full-width"> <.input id="combobox-single-default" label="Country" name="location[country]" type="combobox" value={nil} options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} /> </form>
<form class="gc-full-width"> <.input id="combobox-single-with-placeholder" label="Country" name="location[country]" type="combobox" value={nil} options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} placeholder="Select or type" /> </form>
<form class="gc-full-width"> <.input id="combobox-single-with-value" label="Country" name="location[country]" type="combobox" value="algeria" options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} placeholder="Select or type" /> </form>
<form class="gc-full-width"> <.input id="combobox-single-with-options-with-number-value" label="Country" name="location[country]" type="combobox" value={3} options={[%{label: "Afghanistan", value: 1}, %{label: "Albania", value: 2}, %{label: "Algeria", value: 3}, %{label: "Angola", value: 4}, %{label: "Antarctica", value: 5}, %{label: "Argentina", value: 6}]} placeholder="Select or type" /> </form>
<form class="gc-full-width"> <.input id="combobox-single-required" label="Country" name="location[country]" type="combobox" value="algeria" options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} required placeholder="Select or type" /> </form>
<form class="gc-full-width"> <.input id="combobox-single-with-error" label="Country" name="location[country]" type="combobox" value={nil} options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} errors={["Error helper text"]} placeholder="Select or type" /> </form>
<form class="gc-full-width"> <.input disabled id="combobox-single-disabled" label="Country" name="location[country]" type="combobox" value="algeria" options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} placeholder="Select or type" /> </form>
<form class="gc-full-width"> <.input id="combobox-single-readonly" label="Country" name="location[country]" type="combobox" value="algeria" options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} readonly placeholder="Select or type" /> </form>
<form class="gc-full-width"> <.input id="combobox-single-with-custom-no-results-text" label="Country" name="location[country]" type="combobox" value="algeria" options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} placeholder="Select or type" no_results_text="No countries found." /> </form>
<form class="gc-full-width"> <.input id="combobox-single-with-option-with-long-text" label="Country" name="location[country]" type="combobox" value="long text" options={[%{label: "Really long text Really long text Really long text Really long text Really long text", value: "long text", icon: "plus"}, %{label: "Albania", value: "albania", icon: "plus"}, %{label: "Algeria", value: "algeria", icon: "plus"}]} placeholder="Select or type" /> </form>
<.input id="combobox-single-with-parent-form" label="Country" name="location[country]" type="combobox" value={nil} options={[%{label: "Afghanistan", value: "afghanistan"}, %{label: "Albania", value: "albania"}, %{label: "Algeria", value: "algeria"}, %{label: "Angola", value: "angola"}, %{label: "Antarctica", value: "antarctica"}, %{label: "Argentina", value: "argentina"}]} />