Skip to content

Components / Input Group

Input Group

Prefix and suffix text, decorative icons and accessible actions around a native input or textarea. Square, monospaced styling with native editing, keyboard and form semantics.

Storybook runs locally or as a separately hosted build; no hosted Storybook is configured. Source and setup links match the install revision.

Usage playground

Edit a native text input with a decorative search icon and a named clear action. This is an editing demo, not a search engine. The state control illustrates native availability and explicit error styling.

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from "@/components/ui/yads-input-group";

const layout = { display: 'grid', gap: '.75rem', width: '100%', maxWidth: '28rem' } as const;

Installation

pnpm dlx [email protected] add biehlio/yet-another-design-system/input-group#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40

Input Group samples include their layout styles and need only this registry item.

Run this revision-pinned command in a shadcn-configured project. It installs yads-input-group, the reused Input and Textarea primitives, all three scoped stylesheets and JetBrains Mono automatically. No Tailwind, reset, global CSS, provider or form library is required.

Import the named parts from @/components/ui/yads-input-group (adjust the alias to your project). Every Copy sample button copies a complete React module, including client boundaries, native labels, decorative SVG and any recipe CSS, even when collapsed. No separately installed example dependencies are needed.

Prefix and suffix text

Compose a native label, help text and text addons. Adornments do not change the value or supply an accessible name. This example repeats meaningful prefix information in the connected help text.

Uses HTTPS. Enter only the host; the prefix and slash are not part of the submitted value.

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from "@/components/ui/yads-input-group";

const layout = { display: 'grid', gap: '.75rem', width: '100%', maxWidth: '28rem' } as const;

Textarea and native form

Block addons accommodate multiline fields and wrapping actions. Uncontrolled defaultValue, required, FormData and reset stay native. Focus message uses the actual textarea ref and defaults to type=button, so it cannot accidentally submit.

Plain text

Enter inserts a newline; use Send message to submit. Nothing is sent to a server.

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from "@/components/ui/yads-input-group";

const layout = { display: 'grid', gap: '.75rem', width: '100%', maxWidth: '28rem' } as const;

className customization

Add ordinary CSS to the wrapper or individual parts. This border-width recipe preserves invalid colors, read-only dashes and visible focus. Copy includes the complete CSS and React module; no utility CSS is needed.

React / TSX
'use client';

import { useId, useRef, useState } from 'react';
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from "@/components/ui/yads-input-group";

const layout = { display: 'grid', gap: '.75rem', width: '100%', maxWidth: '28rem' } as const;

Accessibility

  • Label the native control. Use a visible label with htmlFor and a unique control id (useId for repeated examples). The wrapper, prefix and placeholder do not replace a label. Use one control per group.
  • Explain adornments and errors. Hide decorative icons with aria-hidden="true" and focusable="false". Repeat meaningful prefix/suffix information in connected help text. Connect help and error IDs with aria-describedby and set aria-invalid="true" on the control when appropriate. Native constraints remain native; this component does not validate or generate feedback.
  • Name every action. Use button text or aria-label. Tab and Shift+Tab follow DOM order; author addons and controls in reading order to match their visual placement. Enter/Space activate buttons, Enter can submit a valid input form, and Enter in a textarea inserts a newline. Addons themselves are not focusable and do not intercept pointer or keyboard events.
  • Manage availability explicitly. Put disabled/readOnly on the native control, not the div wrapper. A disabled field is skipped and omitted from FormData; a read-only field remains focusable/selectable/submitted. Disable actions that would change an unavailable value. A fieldset disabled attribute disables controls and buttons together.
  • Keep visible focus. Keyboard focus on the control outlines the whole group; buttons retain their own ring. The group is not an additional Tab stop. Light is standalone; a containing .dark class selects dark colors without a provider.

API reference

Import the six named parts from @/components/ui/yads-input-group. Each exports its corresponding …Props type. All parts forward native props, events and refs unchanged; there is no context, value management, generated ID or form-library dependency.

On narrow screens, focus each table and scroll horizontally to read all columns.

Input Group parts, types, defaults and behavior
PartElement / propsDefaultBehavior
InputGroupHTMLDivElement / HTMLAttributes<HTMLDivElement>role="group"Visual wrapper. No value, disabled, readOnly, validation or focus management. Put native state on the control and disable related actions explicitly.
InputGroupAddonHTMLDivElement / HTMLAttributes<HTMLDivElement> & { align?: … }align="inline-start"align: inline-start | inline-end | block-start | block-end. Use block addons for textarea and long content. Layout only: no click-to-focus or generated ARIA.
InputGroupTextHTMLSpanElement / HTMLAttributes<HTMLSpanElement>NonePrefix, suffix or supporting text. Not a label. Use aria-hidden for redundant adornments; connect meaningful instructions with aria-describedby.
InputGroupButtonHTMLButtonElement / ButtonHTMLAttributes<HTMLButtonElement>type="button"Native button. Name every action; use aria-label for icon-only buttons. Explicit type="submit" or type="reset" opts into form behavior. No size/variant/asChild props.
InputGroupInputHTMLInputElement / InputHTMLAttributes<HTMLInputElement>Browser type: textComposes Input without changing its native API. Designed for text-like inputs, not checkboxes/radios/files.
InputGroupTextareaHTMLTextAreaElement / TextareaHTMLAttributes<HTMLTextAreaElement>rows={3}Composes Textarea; native multiline editing and vertical resize. Enter inserts a newline.

Native control props

Native control props and behavior
PropTypeDefaultBehavior
id / name / formNative stringsNot setLabel association, FormData key and optional external form association. Addons are never submitted.
value / onChangeNative value / native change handlerNot setControlled: update value synchronously. Do not switch between controlled and uncontrolled.
defaultValueNative valueNot setUncontrolled initial value restored by browser reset. Controlled state needs application reset handling.
disabledbooleanfalseOn the control: blocks edits, skips Tab and excludes value from FormData. Disable mutating action buttons separately. A disabled fieldset can disable all native descendants.
readOnlybooleanfalseOn the control: dashed group border, focusable/selectable and submitted. Disable mutating actions explicitly.
required / minLength / patternNative constraintsNot setBrowser validation; pattern is input-only. No automatic feedback, aria-invalid or error messages.
aria-invalidNative ARIA valueNot settrue on the control colors the composite border/focus. Connect explanatory error text using aria-describedby; does not itself prevent submission.
className / style / refNative class/style/ref for each partNot setScoped classes are retained. All refs point to the actual named DOM element. Native events, aria-* and data-* pass through.

Other native attributes including type, rows, autoComplete, inputMode, maxLength and placeholder pass through. Modern browsers supporting CSS :has() are required for composite state styling. Long inline addons can crowd text at small widths; use block-start/block-end for long content and multiline fields. The playground resets to editable “components”; its state selector is documentation UI, not a component prop.