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.
'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#e7b31d0e0c9d8b24d53e97ca38b3b68d345e9f40Input 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.
'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.
'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.
'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.
| Part | Element / props | Default | Behavior |
|---|---|---|---|
InputGroup | HTMLDivElement / 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. |
InputGroupAddon | HTMLDivElement / 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. |
InputGroupText | HTMLSpanElement / HTMLAttributes<HTMLSpanElement> | None | Prefix, suffix or supporting text. Not a label. Use aria-hidden for redundant adornments; connect meaningful instructions with aria-describedby. |
InputGroupButton | HTMLButtonElement / 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. |
InputGroupInput | HTMLInputElement / InputHTMLAttributes<HTMLInputElement> | Browser type: text | Composes Input without changing its native API. Designed for text-like inputs, not checkboxes/radios/files. |
InputGroupTextarea | HTMLTextAreaElement / TextareaHTMLAttributes<HTMLTextAreaElement> | rows={3} | Composes Textarea; native multiline editing and vertical resize. Enter inserts a newline. |
Native control props
| Prop | Type | Default | Behavior |
|---|---|---|---|
id / name / form | Native strings | Not set | Label association, FormData key and optional external form association. Addons are never submitted. |
value / onChange | Native value / native change handler | Not set | Controlled: update value synchronously. Do not switch between controlled and uncontrolled. |
defaultValue | Native value | Not set | Uncontrolled initial value restored by browser reset. Controlled state needs application reset handling. |
disabled | boolean | false | On the control: blocks edits, skips Tab and excludes value from FormData. Disable mutating action buttons separately. A disabled fieldset can disable all native descendants. |
readOnly | boolean | false | On the control: dashed group border, focusable/selectable and submitted. Disable mutating actions explicitly. |
required / minLength / pattern | Native constraints | Not set | Browser validation; pattern is input-only. No automatic feedback, aria-invalid or error messages. |
aria-invalid | Native ARIA value | Not set | true on the control colors the composite border/focus. Connect explanatory error text using aria-describedby; does not itself prevent submission. |
className / style / ref | Native class/style/ref for each part | Not set | Scoped 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.