Skip to content

Input Group

A text input that shares one surface with a prefix, suffix or action.

https://

The https:// prefix is not part of the value.

hero.tsx

Usage guidelines

  • Use InputGroup when one text input shares its visual surface with a prefix, suffix or action. Use the standalone Input when nothing shares the surface, and do not absolutely position content over an Input to recreate one.
  • Place the input before every addon in the DOM. The input is the primary control and addons are read or reached after it; only decorative aria-hidden content may come first. Set align="inline-start" (the default) or align="inline-end" on the addon for its visual position; it does not change reading or focus order.
  • Give InputGroupInput an accessible name from a visible label, aria-label or aria-labelledby. Wrap the group in Field with a FieldLabel for a form row; Field also supplies the name, validation, description and error.
  • Field state reaches InputGroupInput, and the group derives its invalid, disabled, read-only and focus visuals from that direct input. Do not repeat those states on addons or restyle them on the group.
  • Treat addon text and icons as supporting content, and mark decorative icons aria-hidden. Put interactive content in a Button, IconButton or link instead of adding click or keyboard handlers to the addon. Those controls keep their own focus and events.
  • Pressing a non-interactive part of the group focuses the input. Pressing an interactive addon targets that control and leaves focus alone, and portalled addon content does not refocus the input. Call preventDefault() in the group's onMouseDown to opt out.
  • The group supports the default input size. A new size belongs on InputGroup, which owns the shared surface and addon layout, rather than on the input and addons separately.

Anatomy

tsx
tsx

InputGroup owns the border, background, focus ring and the non-interactive pointer surface. InputGroupInput owns the native input and its value. InputGroupAddon owns the layout of its supporting content. The direct input can also be another native input that owns its value and states, as in PasswordField.

Examples

Decorative icon

The search icon is decorative and renders visually first through the default inline-start alignment while the input stays first in the DOM. The search box filters the list it sits above and has no room for a visible label, so the input takes aria-label; the <search> element marks it as a search landmark.

  • Product FAQ24 docs
  • Refund policy12 docs
  • API reference48 docs
  • Release notes19 docs
icon.tsx

Suffix

align="inline-end" places a fixed suffix after the value. Clicking the suffix focuses the input. For numeric values with units and steppers, use NumberField instead.

.md

Saved as a Markdown file in the knowledge base.

suffix.tsx

Actions

Interactive addons are real controls: a text Button copies a read-only value, and an IconButton opens a Menu through its trigger's render. Neither moves focus to the input when pressed.

actions.tsx

Disabled

Setting disabled on Field disables InputGroupInput, and the group dims the surface and its non-interactive addons together.

.dify.app

Contact a workspace owner to change the domain.

disabled.tsx

Validation

Inside a Form, the input's native constraints drive FieldError, and the whole group shows the invalid state. Errors appear when the form is submitted, then update as the value changes. Submit the form empty or with uppercase letters to see each message.

.dify.app

Lowercase letters, numbers and hyphens.

validation.tsx

Keyboard

KeyAction
TabMoves focus to the input, then to each interactive addon in DOM order, whatever its visual alignment.
Shift+TabMoves focus back through the interactive addons and the input.

API reference

InputGroup

A compound text-input container for composing an input with prefix, suffix, or action add-ons. Renders a <div> element.

Place the direct InputGroupInput before direct InputGroupAddon children in the DOM and use align for visual placement.

Accepts the props of the element it renders.

InputGroupAddon

Props
PropTypeDefaultDetails
align'inline-end' | 'inline-start''inline-start'
Data attributes
AttributeDescription
data-align

Values: 'inline-start' | 'inline-end'

The visual side of the input the addon sits on.

InputGroupInput

A native input element that automatically works with Field. Renders an <input> element.

Base UI Input docs

Data attributes
AttributeDescription
data-disabled

Present when the input is disabled.

data-valid

Present when the input is in a valid state (when wrapped in Field.Root).

data-invalid

Present when the input is in an invalid state (when wrapped in Field.Root).

data-touched

Present when the input has been touched (when wrapped in Field.Root).

data-dirty

Present when the input's value has changed (when wrapped in Field.Root).

data-filled

Present when the input is filled (when wrapped in Field.Root).

data-focused

Present when the input is focused (when wrapped in Field.Root).