# Input Group

> A text field with affixes inside one outline: a protocol before a domain, a currency or unit, a fixed email domain, a search icon, a unit select or a copy button.

Component · Forms · Halo kit · [Live page](https://ui.twentyfirst.media/halo/components/InputGroup/)

A text field with affixes inside one outline: a protocol before a domain, a currency or unit, a fixed email domain, a search icon, a unit select or a copy button.

- `start` and `end` take text, an `Icon` or a control. Text affixes are read with the field (`aria-describedby`); controls keep their own names and are reached with Tab.
- Takes the props of `TextField` (`label`, `hint`, `error`, `value`, `onChange`, `inputMode` …). `children` replaces the built-in input with your own control (give it `className="tf-input"`).
- The outline shows hover, focus and errors for the whole group; on touch screens the text is 16px so iOS does not zoom.

## Example

```tsx
import { Button, Icon, InputGroup } from "@twentyfirstmedia/halo";

export default function Preview() {
  return (
    <div
      className="tf-grid"
      style={{ "--cols": "1fr 1fr", gap: 16, alignItems: "start" } as React.CSSProperties}
    >
      <InputGroup label="Website" start="https://" placeholder="acme.com" hint="Without www" />
      <InputGroup label="Email alias" end="@acme.com" placeholder="sales" />
      <InputGroup
        label="Monthly budget"
        start="€"
        end="per month"
        inputMode="decimal"
        defaultValue="250"
      />
      <InputGroup
        label="Search people"
        start={<Icon name="search" size={15} />}
        placeholder="Name or email"
      />
      <InputGroup
        label="Weight"
        inputMode="decimal"
        defaultValue="12.5"
        end={
          <select className="tf-input" aria-label="Unit" defaultValue="kg">
            <option>kg</option>
            <option>lb</option>
          </select>
        }
      />
      <InputGroup
        label="API key"
        defaultValue="sk_live_51H8…2xQ"
        readOnly
        end={
          <Button size="sm" variant="ghost" icon="copy">
            Copy
          </Button>
        }
      />
    </div>
  );
}
```

## Props

### InputGroup

| Prop | Type | Notes |
| --- | --- | --- |
| `start?` | `ReactNode` | Before the input: text ("https://", "€") is read with the field; an `Icon`, a `Select` or a `Button` sits in the group as it is. |
| `end?` | `ReactNode` | After the input: text ("@acme.com", "kg"), an icon or a control (copy, unit select …). |
| `children?` | `ReactNode` | Your own control instead of the built-in input (it should carry `className="tf-input"`). |
| `label?` | `string` |  |
| `hint?` | `string` |  |
| `error?` | `string` |  |

### Icon

| Prop | Type | Notes |
| --- | --- | --- |
| `name` | `IconName` | Required |
| `size?` | `number` |  |
| `label?` | `string` |  |
| `className?` | `string` |  |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Button

| Prop | Type | Notes |
| --- | --- | --- |
| `variant?` | `"primary" \| "secondary" \| "soft" \| "ghost" \| "danger" \| "danger-solid"` |  |
| `size?` | `"md" \| "sm"` |  |
| `icon?` | `IconName` |  |
| `iconRight?` | `IconName` |  |
| `disabled?` | `boolean` |  |
| `type?` | `"button" \| "submit" \| "reset"` |  |
| `onClick?` | `(e: MouseEvent<HTMLButtonElement>) => void` |  |
| `children?` | `ReactNode` |  |
| `asChild?` | `boolean` | Render the single child element (a link, a router Link) with the button's look instead of a <button>. |
| `id?` | `string` |  |
| `name?` | `string` | Form field name and value, sent with the form when this button submits it. |
| `value?` | `string` |  |
| `form?` | `string` | The id of the form this button belongs to, when it sits outside it. |
| `title?` | `string` |  |
| `tabIndex?` | `number` |  |
| `autoFocus?` | `boolean` |  |
| `aria-label?` | `string` |  |
| `aria-labelledby?` | `string` |  |
| `aria-describedby?` | `string` |  |
| `aria-expanded?` | `boolean \| "true" \| "false"` | For disclosure and menu triggers: whether what the button controls is open. |
| `aria-controls?` | `string` |  |
| `aria-haspopup?` | `boolean \| "true" \| "false" \| "menu" \| "listbox" \| "tree" \| "grid" \| "dialog"` |  |
| `aria-pressed?` | `boolean \| "true" \| "false" \| "mixed"` | For toggle buttons. |
| `aria-current?` | `boolean \| "true" \| "false" \| "page" \| "step" \| "location" \| "date" \| "time"` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
