Input Group

将任意表单元素水平并排连接。支持 select+input、input+button、input+input 等组合。x-input 的 prefix/suffix/append 适合单输入框自定义,此组件适合多个同级表单元素。`$c['addon']` 辅助类可将文本修饰 span 对齐到 addon 高度。

两个同级 input

<x-input-group label="Full name">
    <x-input name="first" placeholder="First" />
    <x-input name="last"  placeholder="Last" />
</x-input-group>
加载中…
无法加载 HTML

通过 addon class 添加文本装饰

https://
$
.00
@
<x-input-group label="Website">
    <span class="shrink-0 inline-flex items-center bg-base-200 tune-border border-base-300 text-base-content/70 whitespace-nowrap h-[var(--h-field-md)] px-[var(--px-field-md)] text-[length:var(--text-field-md)]">https://</span>
    <x-input name="url" placeholder="example.com" />
</x-input-group>

<x-input-group label="Amount">
    <span class="shrink-0 inline-flex items-center bg-base-200 tune-border border-base-300 text-base-content/70 whitespace-nowrap h-[var(--h-field-md)] px-[var(--px-field-md)] text-[length:var(--text-field-md)]">$</span>
    <x-input type="number" name="amount" value="0" />
    <span class="shrink-0 inline-flex items-center bg-base-200 tune-border border-base-300 text-base-content/70 whitespace-nowrap h-[var(--h-field-md)] px-[var(--px-field-md)] text-[length:var(--text-field-md)]">.00</span>
</x-input-group>

<x-input-group label="Email">
    <x-input name="local" placeholder="user" />
    <span class="shrink-0 inline-flex items-center bg-base-200 tune-border border-base-300 text-base-content/70 whitespace-nowrap h-[var(--h-field-md)] px-[var(--px-field-md)] text-[length:var(--text-field-md)]">@</span>
    <x-input name="domain" placeholder="example.com" />
</x-input-group>
加载中…
无法加载 HTML

select + input — country code + phone

<x-input-group label="Phone">
    <x-select name="country">
        <option value="+81">JP +81</option>
        <option value="+1">US +1</option>
        <option value="+44">UK +44</option>
    </x-select>
    <x-input type="tel" name="phone" placeholder="90-1234-5678" />
</x-input-group>
加载中…
无法加载 HTML

input + submit button — search bar

<x-input-group>
    <x-input type="search" name="q" placeholder="Search…" />
    <x-button type="submit" appearance="solid" color="primary">Go</x-button>
</x-input-group>
加载中…
无法加载 HTML

size — xs / sm / md / lg — wrapper 与 child 的 size 需保持一致

<x-input-group size="xs">
    <x-input size="xs" placeholder="size xs" />
    <x-button size="xs" appearance="outline" color="neutral">Go</x-button>
</x-input-group>
<x-input-group size="sm">
    <x-input size="sm" placeholder="size sm" />
    <x-button size="sm" appearance="outline" color="neutral">Go</x-button>
</x-input-group>
<x-input-group size="md">
    <x-input size="md" placeholder="size md (default)" />
    <x-button size="md" appearance="outline" color="neutral">Go</x-button>
</x-input-group>
<x-input-group size="lg">
    <x-input size="lg" placeholder="size lg" />
    <x-button size="lg" appearance="outline" color="neutral">Go</x-button>
</x-input-group>
加载中…
无法加载 HTML

error — label/hint 变为 text-error

@

Domain not recognised

<x-input-group label="Email" error="Domain not recognised">
    <x-input name="local" placeholder="user" />
    <span class="shrink-0 inline-flex items-center bg-base-200 tune-border border-base-300 text-base-content/70 whitespace-nowrap h-[var(--h-field-md)] px-[var(--px-field-md)] text-[length:var(--text-field-md)]">@</span>
    <x-input name="domain" placeholder="example.com" />
</x-input-group>
加载中…
无法加载 HTML