Input Group
Attaches icons, text, buttons, or a clear control to an input within a single bordered group. The input forwards wire:model unchanged, so a debounced Livewire search is an icon addon, an input and a clear button.
Preview
<x-ui.input-group>
<x-ui.input-group.addon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.3-4.3" />
</svg>
</x-ui.input-group.addon>
<x-ui.input-group.input placeholder="{{ __('Search...') }}" />
<x-ui.input-group.addon align="inline-end">
<x-ui.input-group.button>{{ __('Go') }}</x-ui.input-group.button>
</x-ui.input-group.addon>
</x-ui.input-group>
Installation
php artisan ui:add input-group
Registry contract
php artisan ui:add input-group
writes only the files below. The CLI validates each file hash before writing and asks before it replaces a local change, unless you pass --force.
-
resources/views/components/ui/input-group.blade.php -
resources/views/components/ui/input-group/input.blade.php -
resources/views/components/ui/input-group/addon.blade.php -
resources/views/components/ui/input-group/text.blade.php -
resources/views/components/ui/input-group/button.blade.php -
resources/views/components/ui/input-group/clear.blade.php
- Registry dependencies
- None — installs on its own.
- Packages
-
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: install command, usage, props, guidance and the rules. Copy it, or open a prompt about this component in an assistant.
# Brok UI: Input Group (`input-group`)
Attaches icons, text, buttons, or a clear control to an input within a single bordered group. The input forwards wire:model unchanged, so a debounced Livewire search is an icon addon, an input and a clear button.
Brok UI is a Laravel Blade component registry. Installed components are plain Blade files the app owns.
## Install
```bash
php artisan ui:add input-group
```
## Usage
```blade
<x-ui.input-group>
<x-ui.input-group.addon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.3-4.3" />
</svg>
</x-ui.input-group.addon>
<x-ui.input-group.input placeholder="{{ __('Search...') }}" />
<x-ui.input-group.addon align="inline-end">
<x-ui.input-group.button>{{ __('Go') }}</x-ui.input-group.button>
</x-ui.input-group.addon>
</x-ui.input-group>
```
## Props
- `align` (inline-start|inline-end, default `inline-start`) — Documented catalog control used by the preview workbench.
## Use when
- Use when users must enter freeform information that cannot be reliably selected from a list.
- Attaching an icon, prefix/suffix text, a button or a clear control to an input inside one bordered box.
- Building a search field: icon addon, input and a clear button that share a single focus ring.
## Avoid when
- Do not choose a freeform field when a constrained choice would reduce errors or cognitive load.
- Attaching whole separate controls side by side rather than decorating one input; use button-group instead.
- A plain input with no addon; use input on its own.
## Anti-patterns
- Using freeform entry for a bounded answer set
## Rules
- Use the `<brok:input-group>` tag (or `<x-ui.input-group>`) in Blade; do not rewrite the component.
- Prefer the documented props and variants over utility-class overrides; when a utility must win, use the `!` important modifier.
- Use semantic design tokens (`bg-primary`, `text-muted-foreground`), never raw colour utilities.
- Keep the `data-slot` attributes; they are the styling and test hooks.
## Links
- Docs: https://brokui.dev/docs/components/input-group
- Registry JSON (files, props, contract): https://brokui.dev/r/open/input-group.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
Examples
{{-- A search field: icon addon, a native input that forwards wire:model (or
x-model) unchanged, and a clear control that dispatches a real input event
and keeps focus. It hides while the input shows its placeholder. --}}
<div class="w-full max-w-sm" x-data="{ query: '' }">
<x-ui.input-group>
<x-ui.input-group.addon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.3-4.3" />
</svg>
</x-ui.input-group.addon>
<x-ui.input-group.input type="search" x-model="query" placeholder="{{ __('Search users…') }}" aria-label="{{ __('Search users') }}" />
<x-ui.input-group.clear />
</x-ui.input-group>
<p class="mt-2 text-xs text-muted-foreground" x-show="query" x-cloak>
{{ __('Query:') }} <span class="font-mono text-foreground" x-text="query"></span>
</p>
</div>
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| align | inline-start | inline-end | inline-start | Documented catalog control used by the preview workbench. |
Slots
default— The input plus any addon, button, text or clear children.x-ui.input-group.input— Installed subcomponent from the registry item.x-ui.input-group.addon— Installed subcomponent from the registry item.x-ui.input-group.text— Installed subcomponent from the registry item.x-ui.input-group.button— Installed subcomponent from the registry item.x-ui.input-group.clear— Installed subcomponent from the registry item.
Data slots
Stable hooks for CSS overrides and browser tests.
Behavior
- Renders every child inside a single bordered box with one shared focus ring, instead of separate bordered controls.
- The inner input forwards wire:model and any native attributes unchanged, so a debounced Livewire search is an icon addon, an input and a clear button.
- Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.
Guidance
Collect unpredictable freeform information.
Use when
- Use when users must enter freeform information that cannot be reliably selected from a list.
- Attaching an icon, prefix/suffix text, a button or a clear control to an input inside one bordered box.
- Building a search field: icon addon, input and a clear button that share a single focus ring.
Avoid when
- Do not choose a freeform field when a constrained choice would reduce errors or cognitive load.
- Attaching whole separate controls side by side rather than decorating one input; use button-group instead.
- A plain input with no addon; use input on its own.
Use instead
- Radio or checkbox for bounded choices
- Select or combobox for known options
Anti-patterns
- Using freeform entry for a bounded answer set
- Anatomy
- Theming hooks
Accessibility
- Keyboard
- native
- Focus
managed
- The root carries role="group" so assistive technology announces the input and its addons as one control.
- The focus ring moves to the whole group (focus-within) rather than just the input, matching the visible bordered box.
- Semantic HTML and a stable
data-slotattribute for styling and scripting hooks. - Focus-visible rings use the
ringtoken, so keyboard focus is always visible. - Disabled and invalid states are conveyed to assistive tech, not by color alone.
- Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces in the preview.
- Labels go through
__()and layout uses logical properties (ms-*,text-start), so it mirrors underdir="rtl"— flip the preview to RTL to confirm. - Dark mode uses the same semantic tokens under the
darkclass; high contrast follows forced-color system tokens.
Livewire
Add a stable wire:key when Livewire can reorder this interactive component.
<div wire:key="input-group-{{ $record->id }}">
<x-ui.input-group>
<x-ui.input-group.addon>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.3-4.3" />
</svg>
</x-ui.input-group.addon>
<x-ui.input-group.input placeholder="{{ __('Search...') }}" />
<x-ui.input-group.addon align="inline-end">
<x-ui.input-group.button>{{ __('Go') }}</x-ui.input-group.button>
</x-ui.input-group.addon>
</x-ui.input-group>
</div>
Validation
Validation support: native. Keep the error message connected with aria-describedby.
<form wire:submit="save" class="space-y-2">
<brok:input-group
wire:model="value"
:aria-invalid="$errors->has('value') ? 'true' : 'false'"
aria-describedby="value-error"
/>
@error('value')
<p id="value-error" role="alert">{{ $message }}</p>
@enderror
<brok:button type="submit" wire:loading.attr="disabled">
<span wire:loading.remove>Save</span>
<span wire:loading>Saving…</span>
</brok:button>
</form>
Source
The exact, editable files ui:add writes
into your app. Previews render this same code; there are no preview-only components.
<div role="group" data-slot="input-group" {{ $attributes->merge(['class' => 'flex items-center gap-2 rounded-md border border-input bg-background ps-3 pe-2 text-sm shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-2 focus-within:ring-ring motion-reduce:transition-none']) }}>{{ $slot }}</div>
<input data-slot="input-group-input" {{ $attributes->merge(['class' => 'h-9 w-full flex-1 border-0 bg-transparent p-0 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-0']) }} />
@props(['align' => 'inline-start'])
@php
$aligns = [
'inline-start' => 'order-first',
'inline-end' => 'order-last',
];
$base = 'flex items-center text-muted-foreground [&_svg]:size-4';
$classes = trim($base.' '.($aligns[$align] ?? $aligns['inline-start']));
@endphp
<div data-slot="input-group-addon" data-align="{{ $align }}" {{ $attributes->merge(['class' => $classes]) }}>{{ $slot }}</div>
<span data-slot="input-group-text" {{ $attributes->merge(['class' => 'text-muted-foreground']) }}>{{ $slot }}</span>
<button type="button" data-slot="input-group-button" {{ $attributes->merge(['class' => 'inline-flex h-7 items-center gap-2 rounded-sm px-2 text-sm font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none [&_svg]:size-4']) }}>{{ $slot }}</button>
{{--
Clears the group's input. Dispatches real `input` and `change` events so
`x-model` and Livewire's `wire:model` (with any `.live.debounce` modifier)
see the change exactly as if the user had deleted the text, then returns
focus to the input. Hidden while the input shows its placeholder (a CSS
`:has()` rule, so it also follows a server-side reset with no JS state to
drift); give the input a placeholder for the hide to apply.
--}}
<button
type="button"
data-slot="input-group-clear"
x-data
x-on:click="
const input = $el.closest('[data-slot=input-group]')?.querySelector('[data-slot=input-group-input]');
if (!input) return;
input.value = '';
input.dispatchEvent(new Event('input', { bubbles: true }));
input.dispatchEvent(new Event('change', { bubbles: true }));
input.focus();
"
aria-label="{{ __('Clear') }}"
{{ $attributes->merge(['class' => 'order-last inline-flex size-7 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-[length:var(--ring-width)] focus-visible:ring-ring motion-reduce:transition-none [[data-slot=input-group]:has([data-slot=input-group-input]:placeholder-shown)_&]:hidden']) }}
>
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4">
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.1.2 - Status
- Stable
- License
-
open - Accessibility reviewed
- No review date recorded
- Last breaking change
- No date recorded
- Deprecation
- Not deprecated
- Contract
-
v6 - Foundation
-
≥ 1.0.0