InputGroup
⋯
InputGroup composes Figma Basic Input’s General, Password, and Phone presentations and both Search
Input treatments. It wraps a native 36px input with an 8px radius and places InputGroup.Addon
content beside the editable value.
Use Input for a control without addons.
import { InputGroup } from "@nesra/ui/input-group";
export function AddressField() { return ( <InputGroup label="Workspace address"> <InputGroup.Addon aria-hidden="true">@</InputGroup.Addon> <InputGroup.Input name="workspace" placeholder="my-team" /> </InputGroup> );}InputGroup is also exported from @nesra/ui.
Composition
Section titled “Composition”InputGroup├── InputGroup.Addon (optional prefix)├── InputGroup.Input└── InputGroup.Addon (optional suffix) └── InputGroup.Button (optional action)Examples
Section titled “Examples”Variants
Section titled “Variants”InputGroup.Addon places consumer supplied icons or text beside InputGroup.Input. Password uses
native masking through type="password". The Phone prefix uses the 🇮🇩 emoji and +62. It does not
select a country or alter the submitted value. The chevron and info icons are decorative. Consumers
own any reveal action, country selection, and phone formatting. Emoji appearance depends on the
platform. The icon example imports lucide-react. Add it as a direct dependency if you copy the
example into your app. See Icons.
import { InputGroup } from "@nesra/ui/input-group";import { ChevronDown, Info, LockKeyhole, Mail } from "lucide-react";
export function InputGroupVariantsExample() { return ( <div className="grid w-full max-w-sm gap-nesra-spacing-lg"> <InputGroup label="Input Text" description="This is a hint text to help user" required> <InputGroup.Addon aria-hidden="true"> <Mail size={16} /> </InputGroup.Addon> <InputGroup.Input name="email" type="email" placeholder="Type your email" required /> <InputGroup.Addon align="end" aria-hidden="true"> <Info size={16} /> </InputGroup.Addon> </InputGroup>
<InputGroup label="Password" description="This is a hint text to help user" required> <InputGroup.Addon aria-hidden="true"> <LockKeyhole size={16} /> </InputGroup.Addon> <InputGroup.Input name="password" type="password" placeholder="Type your password" required /> <InputGroup.Addon align="end" aria-hidden="true"> <Info size={16} /> </InputGroup.Addon> </InputGroup>
<InputGroup label="Phone" description="This is a hint text to help user" required> <InputGroup.Addon aria-hidden="true" className="text-nesra-text-body"> <span aria-hidden="true">🇮🇩</span> <span>+62</span> <ChevronDown aria-hidden="true" className="text-nesra-icon-muted" size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Phone number after +62" name="phone" type="tel" placeholder="850-0000-0000" required /> <InputGroup.Addon align="end" aria-hidden="true"> <Info size={16} /> </InputGroup.Addon> </InputGroup> </div> );}States
Section titled “States”Focus an enabled input to inspect the group focus ring. A value creates the Filled presentation.
error displays the Error presentation. disabled prevents editing and form submission.
The whole group takes the focus ring when its input has focus, and the destructive border and ring
when error is set or the input is invalid. Addon text uses text-support and addon icons use
icon-muted. Both switch to the disabled roles when the group is disabled. Colors follow the
field state colors in Light and Dark.
import { InputGroup } from "@nesra/ui/input-group";
export function InputGroupStatesExample() { return ( <div className="grid w-full max-w-sm gap-nesra-spacing-lg"> <InputGroup label="Default" description="Use your work address"> <InputGroup.Input placeholder="Type your email" /> </InputGroup> <InputGroup label="Filled" description="Use your work address"> <InputGroup.Input defaultValue="jessietan@mail.com" /> </InputGroup> <InputGroup label="Error" error="Enter a valid email address"> <InputGroup.Input defaultValue="invalid" /> </InputGroup> <InputGroup label="Disabled" description="Unavailable" disabled> <InputGroup.Input placeholder="Type your email" /> </InputGroup> </div> );}Text addons
Section titled “Text addons”The prefix and suffix are visual context and are not included in the submitted value.
import { InputGroup } from "@nesra/ui/input-group";
export function InputGroupCustomLayoutExample() { return ( <div className="w-full max-w-sm"> <InputGroup label="Workspace address" description="Enter only your workspace name"> <InputGroup.Addon aria-hidden="true">@</InputGroup.Addon> <InputGroup.Input name="workspace" placeholder="my-team" /> <InputGroup.Addon align="end" aria-hidden="true"> .nesra.ai </InputGroup.Addon> </InputGroup> </div> );}Search
Section titled “Search”Figma’s Has Shortcut and Has Button search treatments use InputGroup.Input type="search" with
different trailing content. The shortcut is a visual hint. The consuming page registers any keyboard
shortcut. Place InputGroup.Button type="submit" in a trailing addon inside a form. The group’s
disabled state also disables the button.
import { InputGroup } from "@nesra/ui/input-group";import { Search } from "lucide-react";
export function InputGroupSearchVariantsExample() { return ( <div className="grid w-full max-w-[340px] gap-nesra-spacing-lg"> <InputGroup> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Search docs" name="query" type="search" placeholder="Search..." /> <InputGroup.Addon align="end"> <kbd className="rounded-nesra-xs bg-nesra-surface-card-bg-gray px-nesra-padding-xs type-nesra-body-small-medium text-nesra-text-body"> ⌘ K </kbd> </InputGroup.Addon> </InputGroup>
<InputGroup> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Filled search" defaultValue="Button" type="search" /> <InputGroup.Addon align="end"> <kbd className="rounded-nesra-xs bg-nesra-surface-card-bg-gray px-nesra-padding-xs type-nesra-body-small-medium text-nesra-text-body"> ⌘ K </kbd> </InputGroup.Addon> </InputGroup>
<InputGroup disabled> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Disabled search" type="search" placeholder="Search..." /> <InputGroup.Addon align="end"> <kbd className="rounded-nesra-xs bg-nesra-surface-card-bg-gray px-nesra-padding-xs type-nesra-body-small-medium text-nesra-text-body"> ⌘ K </kbd> </InputGroup.Addon> </InputGroup>
<form onSubmit={(event) => event.preventDefault()}> <InputGroup className="pe-nesra-padding-sm"> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Search components" name="component" type="search" placeholder="Search..." /> <InputGroup.Addon align="end"> <InputGroup.Button type="submit"> <Search aria-hidden="true" size={14} /> Search </InputGroup.Button> </InputGroup.Addon> </InputGroup> </form>
<form onSubmit={(event) => event.preventDefault()}> <InputGroup className="pe-nesra-padding-sm"> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Filled button search" defaultValue="Button" type="search" /> <InputGroup.Addon align="end"> <InputGroup.Button type="submit"> <Search aria-hidden="true" size={14} /> Search </InputGroup.Button> </InputGroup.Addon> </InputGroup> </form>
<form onSubmit={(event) => event.preventDefault()}> <InputGroup className="pe-nesra-padding-sm" disabled> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Disabled button search" type="search" placeholder="Search..." /> <InputGroup.Addon align="end"> <InputGroup.Button type="submit"> <Search aria-hidden="true" size={14} /> Search </InputGroup.Button> </InputGroup.Addon> </InputGroup> </form> </div> );}Controlled filtering
Section titled “Controlled filtering”import { InputGroup } from "@nesra/ui/input-group";import { Search } from "lucide-react";import { useState } from "react";
const components = ["Button", "Input", "InputGroup", "Text Area"];
export function InputGroupSearchControlledExample() { const [query, setQuery] = useState(""); const matches = components.filter((component) => component.toLowerCase().includes(query.toLowerCase()), );
return ( <div className="grid w-full max-w-[340px] gap-nesra-spacing-md"> <InputGroup> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Filter components" placeholder="Filter components..." type="search" value={query} onValueChange={setQuery} /> </InputGroup> <p aria-live="polite" className="type-nesra-body-small-regular text-nesra-text-support"> {matches.length} matching components </p> <ul className="grid gap-nesra-spacing-xs"> {matches.map((component) => ( <li key={component}>{component}</li> ))} </ul> </div> );}Form submission
Section titled “Form submission”import { InputGroup } from "@nesra/ui/input-group";import { Search } from "lucide-react";import { useState, type SubmitEvent } from "react";
export function InputGroupSearchFormExample() { const [submittedQuery, setSubmittedQuery] = useState("");
function handleSubmit(event: SubmitEvent<HTMLFormElement>) { event.preventDefault(); setSubmittedQuery(String(new FormData(event.currentTarget).get("query") ?? "")); }
return ( <div className="grid w-full max-w-[340px] gap-nesra-spacing-md"> <form onSubmit={handleSubmit}> <InputGroup className="pe-nesra-padding-sm"> <InputGroup.Addon aria-hidden="true"> <Search size={16} /> </InputGroup.Addon> <InputGroup.Input aria-label="Search the component library" name="query" placeholder="Search..." required type="search" /> <InputGroup.Addon align="end"> <InputGroup.Button type="submit"> <Search aria-hidden="true" size={14} /> Find </InputGroup.Button> </InputGroup.Addon> </InputGroup> </form> <output className="type-nesra-body-small-regular text-nesra-text-support"> {submittedQuery ? `Submitted query: ${submittedQuery}` : "Submit a search to see its value."} </output> </div> );}Accessibility
Section titled “Accessibility”labelassociates a visible label withInputGroup.Input. Without it, name the input witharia-labeloraria-labelledby. A placeholder and decorative addon are not labels.descriptionbecomes the input’s accessible description.errorreplaces it with an associated alert. The consuming form owns validation timing and message content.- A visual prefix such as
+62is not included in the submitted value. Include its meaning in the accessible name or description when needed. Mark decorative icons witharia-hidden="true". - Set
requiredonInputGroup.Inputfor native validation. The group prop shows the marker.disabledon the group disables the input. The input’s ref points to the native element. - For search, set
type="search"onInputGroup.Inputand give it an accessible name. A search icon or placeholder does not name the field. Keep a submit button outsidearia-hiddencontent.
API reference
Section titled “API reference”InputGroup
Section titled “InputGroup”The root renders the group and provides its disabled state to the child input. It accepts native
div props and forwards its ref to the group element.
| Prop | Type | Default | Effect |
|---|---|---|---|
children |
ReactNode |
— | Renders the input and addons. |
label |
ReactNode |
— | Adds a visible Base UI Field label. |
description |
ReactNode |
— | Adds help text below the group. |
error |
FieldError |
— | Displays an associated validation message. |
required |
boolean |
false |
Shows the required marker only. |
disabled |
boolean |
false |
Disables the child input. |
See the FieldError type for validation matching.
InputGroup.Input
Section titled “InputGroup.Input”The editable part renders a Base UI input and accepts its native input attributes, including
type, name, value, defaultValue, onChange, and onValueChange. Set required on this part
for native validation. Its ref points to the input element. The root’s disabled state also
disables this part.
InputGroup.Addon
Section titled “InputGroup.Addon”The addon renders a span for icons or text and accepts native span props. Its ref points to the
span element. DOM order determines whether it appears before or after the input. Addons must be
inside InputGroup.
| Prop | Type | Default | Effect |
|---|---|---|---|
align |
"start" | "end" |
"start" |
Pushes the addon toward the trailing edge when end. |
InputGroup.Button
Section titled “InputGroup.Button”The compact action accepts Button props except variant and size. It renders inside an
InputGroup.Addon and inherits the group’s disabled state. Set type="submit" when the action
submits a form. Its ref points to the button element.
The visual values come from the color roles, typography roles, layout scale, and shape and elevation tokens.