This page as markdown: /input-group.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

InputGroup

Status: stable

An Input with addons inside the same field: a prefix or suffix ("https://", ".com", "

quot;), an icon, or a borderless Button such as copy or reveal. One shell, one focus ring, one error state; a Field's label and error wiring reaches the Input inside.

Keywords: input group, input addon, prefix, suffix, adornment, url input, currency input, password reveal, copy field, icon in input

Usage

Use InputGroup when something belongs inside the field with the text: a unit, a fixed prefix, an icon, or a small action on the value itself (copy, reveal, clear). Use Field's trailing for an action beside the field (Apply next to a promo code), SearchInput for search, and NumberField for numbers with steppers.

Best practices

Props

Name Type Default Description
leading ReactNode — Inside the field, before the text: a prefix ("https://", "
quot;), an icon, or a borderless Button.
trailing ReactNode — Inside the field, after the text: a suffix (".com", "kg"), an icon, or a borderless Button (copy, reveal, clear).
children ReactElement — The single <Input />. It keeps its own props and type; the group takes over its border, fill and focus ring.
id / required / disabled / aria-describedby / aria-invalid control props — Forwarded to the Input, not set on the group. This is how a Field's wiring reaches the text box when the group is its child.
className string — Layout classes for the group (width, margins).

Tokens used

field-border, field, ring, destructive, muted-foreground, foreground

Motion

Accessibility

Related

Examples

Prefix and suffix

import { Field, Input, InputGroup } from "@sableui/react"

<Field label="Website"><InputGroup leading="https://" trailing=".com"><Input placeholder="example" /></InputGroup></Field>

Leading icon

import { Field, Icon, Input, InputGroup } from "@sableui/react"

<Field label="Email"><InputGroup leading={<Icon name="mail" />}><Input type="email" placeholder="you@example.com" /></InputGroup></Field>

Copy button

import { Button, Field, Icon, Input, InputGroup } from "@sableui/react"

<Field label="API key"><InputGroup trailing={<Button variant="ghost" size="icon-sm" aria-label="Copy key" onClick={copy}><span aria-hidden="true" className="motion-icon-swap"><span data-active={!copied} className="inline-flex"><Icon name="copy" /></span><span data-active={copied} className="inline-flex"><Icon name="check" /></span></span></Button>}><Input readOnly value={key} /></InputGroup></Field>

Password with reveal

import { Button, Field, Icon, Input, InputGroup } from "@sableui/react"

<Field label="Password"><InputGroup trailing={<Button variant="ghost" size="icon-sm" aria-label={shown ? "Hide password" : "Show password"} aria-pressed={shown} onClick={() => setShown(!shown)}><Icon name={shown ? "eye-off" : "eye"} /></Button>}><Input type={shown ? "text" : "password"} autoComplete="current-password" /></InputGroup></Field>