# Input Group

Inputs and textareas with aligned icons, helper content, and actions.

Use Input Group to combine a text input or textarea with icons, text, keyboard hints, and actions inside one surface. Wrap it in [Field](/components/field/) when the control needs a visible label, description, or validation message.

```tsx
import { InputGroup } from "@zentara-co/zenos-ui";

function InputGroupExample() {
  return (
    <InputGroup.Root className="w-full max-w-md">
      <InputGroup.Addon>https://</InputGroup.Addon>
      <InputGroup.Control aria-label="Email" placeholder="yourname@email.com" />
      <InputGroup.Addon align="inline-end">
        <InputGroup.Button>Send</InputGroup.Button>
      </InputGroup.Addon>
    </InputGroup.Root>
  );
}
```

## Import

```tsx
import { InputGroup } from "@zentara-co/zenos-ui";
```

## Addon alignment

Set `align` on an addon to position it independently of DOM order:

- `inline-start`: before the input, or on its right in RTL.
- `inline-end`: after the input, or on its left in RTL.
- `block-start`: a full-width header above the control.
- `block-end`: a full-width footer below the control.

For new compositions, put the input or textarea first in the DOM, followed by addons. CSS alignment changes visual placement while keyboard focus still reaches the input before addon buttons. Clicking non-interactive addon content focuses the control; buttons, links, and other interactive content keep their own behavior.

Omitting `align` preserves existing DOM-order placement. `InputGroup.Control` remains the same input component as `InputGroup.Input`. Place interactive actions inside an aligned `InputGroup.Addon` using `InputGroup.Button`.

```tsx
import { Field, Grid, InputGroup } from "@zentara-co/zenos-ui";

function InputGroupAlignmentExample() {
  const alignments = ["inline-start", "inline-end", "block-start", "block-end"] as const;
  return (
    <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full">
      {alignments.map((align) => (
        <Field.Root key={align}>
          <Field.Label>{align}</Field.Label>
          <InputGroup>
            <InputGroup.Input placeholder="Enter a value" />
            <InputGroup.Addon align={align}>
              <InputGroup.Text>{align}</InputGroup.Text>
            </InputGroup.Addon>
          </InputGroup>
        </Field.Root>
      ))}
    </Grid>
  );
}
```

## Textarea and block content

Use `InputGroup.Textarea` for a multiline control with a correctly typed textarea ref, native `rows`, `maxLength`, and form props. The group grows to fit a textarea or block-aligned addons instead of retaining a fixed single-line height.

Place header and footer content in block-aligned addons. `InputGroup.Text` works for filenames, units, or character counts, and compact `InputGroup.Button` actions fit inside the addon. The example keeps value state local and sends the message through an explicit callback.

```tsx
import { Field, InputGroup, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function InputGroupTextareaExample() {
  const [message, setMessage] = useState("");
  const [submitted, setSubmitted] = useState("");
  return (
    <Stack gap="3" className="w-full max-w-lg">
      <Field.Root>
        <Field.Label>Support message</Field.Label>
        <InputGroup>
          <InputGroup.Textarea
            value={message}
            onChange={(event) => setMessage(event.target.value)}
            maxLength={280}
            rows={4}
            placeholder="How can we help?"
          />
          <InputGroup.Addon align="block-start">
            <InputGroup.Text>Workspace support</InputGroup.Text>
          </InputGroup.Addon>
          <InputGroup.Addon align="block-end">
            <InputGroup.Text>{message.length}/280</InputGroup.Text>
            <InputGroup.Button disabled={!message.trim()} onClick={() => setSubmitted(message)}>
              Send message
            </InputGroup.Button>
          </InputGroup.Addon>
        </InputGroup>
        <Field.Description>Share up to 280 characters.</Field.Description>
      </Field.Root>
      <Text size="s" color="subtle" aria-live="polite">
        {submitted ? `Sent: ${submitted}` : "No message sent."}
      </Text>
    </Stack>
  );
}
```

## Icons, keyboard hints, menus, and loading

Addons accept arbitrary React content, including icons, [Kbd](/components/kbd/), tooltips, menus, and status indicators. Label icon-only actions and hide decorative icons from assistive technology.

`InputGroup.Button` supports Button's variants, `sm | md | lg` sizes, loading state, and native props. It defaults to a compact `sm` ghost button with `type="button"`; set `type="submit"` deliberately in a form. Use a trigger's `render` prop to compose a menu or tooltip with the grouped button rather than nesting buttons. Its own `render` prop also supports button-compatible custom controls.

```tsx
import { CaretDownIcon, MagnifyingGlassPlusIcon } from "@phosphor-icons/react";
import { DropdownMenu, InputGroup, Kbd, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function InputGroupAccessoriesExample() {
  const [action, setAction] = useState("No file action selected.");
  return (
    <Stack gap="4" className="w-full max-w-lg">
      <InputGroup>
        <InputGroup.Input aria-label="Search commands" placeholder="Search commands" />
        <InputGroup.Addon align="inline-start">
          <MagnifyingGlassPlusIcon aria-hidden />
        </InputGroup.Addon>
        <InputGroup.Addon align="inline-end">
          <Kbd.Group>
            <Kbd>Ctrl</Kbd>
            <Kbd>K</Kbd>
          </Kbd.Group>
        </InputGroup.Addon>
      </InputGroup>
      <InputGroup>
        <InputGroup.Input aria-label="File name" defaultValue="report.csv" />
        <InputGroup.Addon align="inline-end">
          <DropdownMenu.Root>
            <DropdownMenu.Trigger render={<InputGroup.Button aria-label="File actions" />}>
              <CaretDownIcon aria-hidden />
            </DropdownMenu.Trigger>
            <DropdownMenu.Content align="end">
              <DropdownMenu.Item onClick={() => setAction("Rename selected.")}>
                Rename
              </DropdownMenu.Item>
              <DropdownMenu.Item onClick={() => setAction("Download selected.")}>
                Download
              </DropdownMenu.Item>
            </DropdownMenu.Content>
          </DropdownMenu.Root>
        </InputGroup.Addon>
      </InputGroup>
      <InputGroup>
        <InputGroup.Input
          aria-label="Background search"
          aria-busy="true"
          readOnly
          value="Searching workspace..."
        />
        <InputGroup.Addon align="inline-end">
          <InputGroup.Button isLoading loadingLabel="Searching" disabled>
            Searching
          </InputGroup.Button>
        </InputGroup.Addon>
      </InputGroup>
      <Text size="s" color="subtle" aria-live="polite">
        {action}
      </Text>
    </Stack>
  );
}
```

## Variants

Choose `default`, `filled`, or `none` to match nearby [Inputs](/components/input/). Input Group uses the same corner radius, border, fill, hover treatment, typography, and size scale as Input. The root owns the border and background; nested controls stay chromeless, including when disabled or invalid. Inline addons share the control's outer padding with a compact gap before the text. Variants describe the surface, independently of the field's state.

```tsx
import { InputGroup, Stack } from "@zentara-co/zenos-ui";

function InputGroupVariantsExample() {
  return (
    <Stack gap="3" className="w-full max-w-lg">
      <InputGroup.Root variant="default">
        <InputGroup.Addon>Prefix</InputGroup.Addon>
        <InputGroup.Control aria-label="Default appearance" placeholder="Placeholder" />
        <InputGroup.Addon align="inline-end">
          <InputGroup.Button>Suffix</InputGroup.Button>
        </InputGroup.Addon>
      </InputGroup.Root>
      <InputGroup.Root variant="filled">
        <InputGroup.Addon>Prefix</InputGroup.Addon>
        <InputGroup.Control aria-label="Filled appearance" placeholder="Placeholder" />
        <InputGroup.Addon align="inline-end">
          <InputGroup.Button>Suffix</InputGroup.Button>
        </InputGroup.Addon>
      </InputGroup.Root>
      <InputGroup.Root variant="none">
        <InputGroup.Addon>Prefix</InputGroup.Addon>
        <InputGroup.Control aria-label="None appearance" placeholder="Placeholder" />
        <InputGroup.Addon align="inline-end">
          <InputGroup.Button>Suffix</InputGroup.Button>
        </InputGroup.Addon>
      </InputGroup.Root>
    </Stack>
  );
}
```

## State

Use native control props and `Field.Root` to express state rather than changing the group's variant:

- **Default:** editable and focusable. Focusing the input or textarea activates the group's focused border. The `default` variant uses Input's pressed background; `filled` and `none` stay transparent while focused.
- **Disabled:** `Field.Root disabled` disables its control. Disable independent addon buttons explicitly, and keep a description explaining why the field is unavailable.
- **Invalid:** `Field.Root invalid` supplies `aria-invalid`; pair it with `Field.Error` to associate the validation message. The group uses a 2px danger border and accent red subtlest fill.
- **Read-only:** pass `readOnly` to the input or textarea. The value remains focusable and selectable without allowing edits.

Addons and default grouped buttons do not add a hover background. Use `className` if an action needs its own hover treatment, while preserving visible focus styling.

```tsx
import { Field, Grid, InputGroup } from "@zentara-co/zenos-ui";

function InputGroupStatesExample() {
  return (
    <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full">
      <Field.Root>
        <Field.Label>Default handle</Field.Label>
        <InputGroup>
          <InputGroup.Input defaultValue="zenos" />
          <InputGroup.Addon align="inline-start">
            <InputGroup.Text>@</InputGroup.Text>
          </InputGroup.Addon>
        </InputGroup>
        <Field.Description>Focus the input to see the active group border.</Field.Description>
      </Field.Root>
      <Field.Root disabled>
        <Field.Label>Disabled handle</Field.Label>
        <InputGroup>
          <InputGroup.Input defaultValue="managed-workspace" />
          <InputGroup.Addon align="inline-start">
            <InputGroup.Text>@</InputGroup.Text>
          </InputGroup.Addon>
          <InputGroup.Addon align="inline-end">
            <InputGroup.Button disabled>Check</InputGroup.Button>
          </InputGroup.Addon>
        </InputGroup>
        <Field.Description className="text-text-subtle">
          Your organization manages this handle.
        </Field.Description>
      </Field.Root>
      <Field.Root invalid>
        <Field.Label>Invalid handle</Field.Label>
        <InputGroup>
          <InputGroup.Input defaultValue="zenos!" />
          <InputGroup.Addon align="inline-start">
            <InputGroup.Text>@</InputGroup.Text>
          </InputGroup.Addon>
        </InputGroup>
        <Field.Error>Use letters, numbers, and hyphens only.</Field.Error>
      </Field.Root>
      <Field.Root>
        <Field.Label>Read-only handle</Field.Label>
        <InputGroup>
          <InputGroup.Input readOnly value="zenos-design" />
          <InputGroup.Addon align="inline-start">
            <InputGroup.Text>@</InputGroup.Text>
          </InputGroup.Addon>
        </InputGroup>
        <Field.Description>You can focus and copy this handle, but not edit it.</Field.Description>
      </Field.Root>
    </Grid>
  );
}
```

## Sizes

The root's `sm`, `md`, and `lg` sizes set single-line heights of 36px, 40px, and 44px. Inputs inherit this scale. Textareas use size-dependent minimum heights and may grow; compact buttons use their own Button size.

```tsx
import { InputGroup, Stack } from "@zentara-co/zenos-ui";

function InputGroupSizesExample() {
  return (
    <Stack gap="3" className="w-full max-w-lg">
      {(["sm", "md", "lg"] as const).map((size) => (
        <InputGroup.Root key={size} size={size}>
          <InputGroup.Addon>{size}</InputGroup.Addon>
          <InputGroup.Control aria-label={`${size} search`} placeholder="Search assets" />
          <InputGroup.Addon align="inline-end">
            <InputGroup.Button size={size}>Search</InputGroup.Button>
          </InputGroup.Addon>
        </InputGroup.Root>
      ))}
    </Stack>
  );
}
```

## Custom styling and controls

Every part accepts the usual `className` prop. You do not need a variant prop to customize the surface, control, text, or actions. Keep focus and invalid states distinguishable and retain an accessible label.

```tsx
import { Field, InputGroup } from "@zentara-co/zenos-ui";

function InputGroupCustomExample() {
  return (
    <Field.Root className="w-full max-w-md">
      <Field.Label>Workspace URL</Field.Label>
      <InputGroup className="rounded-full border-border-brand">
        <InputGroup.Input placeholder="your-workspace" className="font-medium" />
        <InputGroup.Addon align="inline-start">
          <InputGroup.Text className="text-text-brand">https://</InputGroup.Text>
        </InputGroup.Addon>
        <InputGroup.Addon align="inline-end">
          <InputGroup.Button className="rounded-full text-text-brand">Open</InputGroup.Button>
        </InputGroup.Addon>
      </InputGroup>
    </Field.Root>
  );
}
```

`InputGroup.Control render` composes another input-compatible control while keeping group styling and props. For multiline content, prefer the dedicated `InputGroup.Textarea` rather than passing a textarea to an input-typed ref. A consumer-owned control can also participate directly by setting `data-slot="input-group-control"` on its native input or textarea; provide its own label, field associations, and chromeless styling. The root uses that slot to detect focus, invalid, and disabled state.

## Variants

default, filled, none

## Sizes

sm, md, lg

## Anatomy

```text
InputGroup.Root
InputGroup.Input
InputGroup.Textarea
InputGroup.Addon
InputGroup.Text
InputGroup.Button
InputGroup.Control
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| variant | InputVariant | default | Surface inherited by the control. |
| size | sm \| md \| lg | md | Height inherited by controls. Buttons have their own size. |
| Addon.align | inline-start \| inline-end \| block-start \| block-end | — | Visual addon placement, with logical inline positions for RTL. Omit to retain legacy DOM-order placement. Block addons enable auto-height layout. |
| Control.render | ReactElement \| function | — | Composes group behavior with another input-like control. |
| Textarea props | TextareaProps | — | Native textarea props and an HTMLTextAreaElement ref. Inherits size and variant; Field supplies labels, descriptions, validation, and disabled state. |
| Button.variant / size | ButtonVariant / sm \| md \| lg | ghost / sm | Compact action styling, independent of the group's single-line height. Supports Button loading and native props; type defaults to button. |
| Button.render | ReactElement \| function | — | Composes a button-compatible control without an extra interactive wrapper. |
| Text props | HTMLAttributes<HTMLSpanElement> | — | Non-interactive helper text, units, counts, or icons with native span props and ref. |
| className | string | — | Each part accepts custom styling. Root native div props and ref remain available; Input is an alias of Control. |
| native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

`InputGroup` exposes a visual group but does not replace a field label. Use `Field.Label` or provide the control with an accessible name. Keep input-first DOM order for aligned layouts, and label icon-only buttons with `aria-label`. Addons are not focusable unless they contain an interactive control.

Use native input and textarea props for required fields, read-only content, and form submission. A disabled input does not automatically disable independent addon buttons. Keyboard hints are descriptive only; register any shortcut behavior in the owning application.

Source: https://zenos-ui.pages.dev/components/input-group/