Input Group

Renders a group of related inputs with a shared label, help text, and errors.

Read more Read less

This component is used when two or more inputs belong together logically — for example, a budget range (min/max), a date range, or any pair of related values that share a single label.

Child inputs should set label_hidden={true} so that only the group label is visible. The group label replaces individual input labels.

Examples

<.input_group id="budget-range" label="Budget per person">
  <:help>Includes taxes</:help>
  <.input type="money" field={@form[:budget_min]} placeholder="Min" label_hidden />
  <.input type="money" field={@form[:budget_max]} placeholder="Max" label_hidden />
</.input_group>

<.input_group id="age-range" label="Age range" errors={["Enter both values"]}>
  <.input type="number" field={@form[:age_min]} placeholder="Min" label_hidden />
  <.input type="number" field={@form[:age_max]} placeholder="Max" label_hidden />
</.input_group>

Repeated rows

When the group is one row of a repeatable list, add a :remove slot for an icon-only remove button after the inputs. Set align="start" when a child input shows help or error text below it, so the inputs and the button stay aligned along their top edge instead of drifting with the text.

<.input_group id="phone-0" label="Phone number" align="start">
  <:remove label="Remove phone number" on_click={JS.push("remove_phone", value: %{index: 0})} />
  <.input type="dropdown" field={phone[:type]} options={@types} label_hidden fit_content />
  <.input type="phone" field={phone[:number]} label_hidden />
</.input_group>

For extensions, use x or #, e.g. (505) 923 1234x202

Attribute Type Documentation Default Value
Required id * :string
Required label * :string
errors :list

Errors to display below the group.

[]
required :boolean false
align :string

Vertical alignment of the inputs in the row

"center"
class :any

Additional classes to add to the parent.

[]
rest :global
help :slot

Helper text appearing below the input group

Show slot attributes Hide slot attributes
icon :string

An icon name from the Icon component

<:help>For extensions, use x or #, e.g. (505) 923 1234x202</:help>
remove :slot

An icon-only remove button rendered after the inputs

Show slot attributes Hide slot attributes
Required label * :string

The accessible name of the button

Required on_click * %JS{}
Required inner_block * :slot
<.input type="dropdown" id="phone-number-0-type" name="phone[type]" value="work" label="Phone type" label_hidden={true} fit_content={true} options={[%{label: "Work", value: "work"}, %{label: "Mobile", value: "mobile"}, %{label: "Fax", value: "fax"}]} />
<.input type="phone" id="phone-number-0-number" name="phone[number]" value="" label="Phone number" label_hidden={true} show_default_help={false} />