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>
–

Includes taxes

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>Includes taxes</: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
<.stack space="none">
  <.input type="money" name="budget_min" value="100" label="Minimum" placeholder="Min" label_hidden={true} />
</.stack>
<span>&ndash;</span>
<.stack space="none">
  <.input type="money" name="budget_max" value="250" label="Maximum" placeholder="Max" label_hidden={true} />
</.stack>