InputGroup
Connect inputs, selectors, date pickers, buttons, and addons in one row. Adjacent borders overlap and inner corner radii are removed. Each control keeps its own value, events, and keyboard behavior.
Import
import { HuiInputGroup, HuiInputGroupAddon } from '@nscode/handy-ui'
import type { InputGroupProps } from '@nscode/handy-ui'
Examples
Search with a Selector, Input, and Button
Direct children can be Input, AutoComplete, InputNumber, Select, Cascader, TreeSelect, DatePicker, TimePicker, Button, or Addon. Avoid adding a wrapper around a control that should join the group.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiInputGroup, HuiSelect, HuiInput, HuiButton, HuiSpace } from '@nscode/handy-ui'
const field = ref('name')
const keyword = ref('')
const result = ref('No search yet')
const fields = [
{ label: 'By name', value: 'name' },
{ label: 'By code', value: 'code' }
]
const search = () => {
result.value = `${field.value}: ${keyword.value || 'Empty'}`
}
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiInputGroup aria-label="Search conditions">
<HuiSelect v-model="field" :options="fields" style="width: 120px" />
<HuiInput
v-model="keyword"
placeholder="Enter a keyword"
style="width: 220px"
@keydown.enter="search"
/>
<HuiButton type="primary" @click="search">Search</HuiButton>
</HuiInputGroup>
<span>{{ result }}</span>
</HuiSpace>
</template>
Prefix and Suffix Addons
HuiInputGroupAddon has a default slot for text or an icon. Its height stretches with controls in the same row.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiInputGroup, HuiInputGroupAddon, HuiInput, HuiIcon, HuiSpace } from '@nscode/handy-ui'
const domain = ref('example')
const amount = ref('100')
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiInputGroup aria-label="Website"
><HuiInputGroupAddon>https://</HuiInputGroupAddon
><HuiInput v-model="domain" style="width: 200px" /><HuiInputGroupAddon
>.com</HuiInputGroupAddon
></HuiInputGroup
>
<HuiInputGroup aria-label="Amount"
><HuiInputGroupAddon><HuiIcon name="info" /></HuiInputGroupAddon
><HuiInput v-model="amount" style="width: 160px" /><HuiInputGroupAddon
>USD</HuiInputGroupAddon
></HuiInputGroup
>
</HuiSpace>
</template>
Date Picker Combination
<script setup lang="ts">
import { ref } from 'vue'
import {
HuiInputGroup,
HuiInputGroupAddon,
HuiDatePicker,
HuiButton,
HuiSpace
} from '@nscode/handy-ui'
import type { DatePickerValue } from '@nscode/handy-ui'
const date = ref<DatePickerValue>(null)
const result = ref('No query yet')
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiInputGroup
><HuiInputGroupAddon>Date</HuiInputGroupAddon
><HuiDatePicker v-model="date" placeholder="Choose a date" style="width: 220px" /><HuiButton
@click="result = String(date || 'No date selected')"
>Query</HuiButton
></HuiInputGroup
>
<span>{{ result }}</span>
</HuiSpace>
</template>
Three Sizes
A control's explicit size takes priority over InputGroup. When group size is omitted, each control retains its normal FormItem, Form, and global configuration fallback.
<script setup lang="ts">
import {
HuiInputGroup,
HuiInputGroupAddon,
HuiInput,
HuiButton,
HuiSpace
} from '@nscode/handy-ui'
import type { ComponentSize } from '@nscode/handy-ui'
const sizes: ComponentSize[] = ['large', 'default', 'small']
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiInputGroup v-for="size in sizes" :key="size" :size="size"
><HuiInputGroupAddon>{{ size }}</HuiInputGroupAddon
><HuiInput placeholder="Shared size" style="width: 200px" /><HuiButton
>Action</HuiButton
></HuiInputGroup
>
</HuiSpace>
</template>
Dynamic Disabled State
For input controls, disabled=false cannot undo a disabled InputGroup or Form. Button preserves its own and ButtonGroup's explicit override rules.
<script setup lang="ts">
import { ref } from 'vue'
import {
HuiInputGroup,
HuiInput,
HuiSelect,
HuiDatePicker,
HuiButton,
HuiSwitch,
HuiSpace
} from '@nscode/handy-ui'
const disabled = ref(true)
const options = [{ label: 'Option one', value: 'one' }]
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiSpace><span>Disable group</span><HuiSwitch v-model="disabled" /></HuiSpace>
<HuiInputGroup :disabled="disabled"
><HuiSelect :options="options" placeholder="Choose" style="width: 100px" /><HuiInput
placeholder="Enter text"
style="width: 160px"
/><HuiDatePicker style="width: 170px" /><HuiButton>Confirm</HuiButton></HuiInputGroup
>
</HuiSpace>
</template>
Inline and Block Layouts
The default layout is inline. block fills the parent. Input controls without inline width or inline-size share the remaining width equally; buttons and addons keep their own widths. An explicit percentage is relative to the group. min-width and max-width are constraints, not explicit widths.
<script setup lang="ts">
import {
HuiInputGroup,
HuiInputGroupAddon,
HuiInput,
HuiButton,
HuiSpace
} from '@nscode/handy-ui'
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiInputGroup
><HuiInputGroupAddon>Inline</HuiInputGroupAddon
><HuiInput placeholder="Content layout" style="width: 200px" /><HuiButton
>Action</HuiButton
></HuiInputGroup
>
<HuiInputGroup block
><HuiInput placeholder="Fixed 25%" style="width: 25%" /><HuiInput
placeholder="Remaining space"
/><HuiButton>Content width</HuiButton></HuiInputGroup
>
<HuiInputGroup block
><HuiInput placeholder="Half remaining width" style="min-width: 0" /><HuiInput
placeholder="Half remaining width"
style="min-width: 0"
/></HuiInputGroup>
<HuiInputGroup block
><HuiInputGroupAddon>https://</HuiInputGroupAddon
><HuiInput placeholder="Input fills remaining space" /><HuiInputGroupAddon
>.com</HuiInputGroupAddon
><HuiButton>Check domain</HuiButton></HuiInputGroup
>
</HuiSpace>
</template>
Form Inheritance and Explicit Overrides
Input sizes follow: control → InputGroup → FormItem → Form → global configuration. InputGroup merges FormItem/Form sizes and Form disabled state into its context so grouped buttons align with inputs. Button sizes follow: button → ButtonGroup → InputGroup → ConfigProvider.button.size → global size → default. Button disabled state takes the first explicit value from button → ButtonGroup → InputGroup; false overrides an inherited value. Buttons outside InputGroup inherit neither Form size nor Form disabled state and can remain usable as Edit actions. An independent Form cuts off an outer input group. Existing readonly precedence is preserved.
<script setup lang="ts">
import { ref } from 'vue'
import {
HuiForm,
HuiFormItem,
HuiInputGroup,
HuiInputGroupAddon,
HuiInput,
HuiButton,
HuiSpace
} from '@nscode/handy-ui'
const disabled = ref(true)
</script>
<template>
<HuiForm size="large" :disabled="disabled">
<HuiFormItem label="Inherited small" size="small"
><HuiInputGroup
><HuiInputGroupAddon>Prefix</HuiInputGroupAddon
><HuiInput placeholder="Inherited FormItem small" style="width:200px" /><HuiButton
>Grouped small</HuiButton
></HuiInputGroup
></HuiFormItem
>
<HuiFormItem label="Own default"
><HuiInputGroup size="large"
><HuiInput
size="default"
placeholder="Own default overrides group large"
style="width:200px"
/><HuiButton size="default">Matching default</HuiButton></HuiInputGroup
></HuiFormItem
>
<HuiSpace
><HuiButton @click="disabled = !disabled"
>Outside group: {{ disabled ? 'Edit' : 'Disable form' }}</HuiButton
><span>Form disabled={{ disabled }}</span></HuiSpace
>
</HuiForm>
</template>
Comparing Input Prefix and Suffix Slots
For one input with attached content, use Input prepend and append. Use InputGroup for several independent controls. InputGroup joins only the outer border and preserves controls nested inside Input slots.
<script setup lang="ts">
import {
HuiInputGroup,
HuiInputGroupAddon,
HuiInput,
HuiButton,
HuiSpace
} from '@nscode/handy-ui'
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiInput placeholder="One input with attached content" style="width: 360px"
><template #prepend>https://</template><template #append>.com</template></HuiInput
>
<HuiInputGroup
><HuiInputGroupAddon>Group</HuiInputGroupAddon
><HuiInput placeholder="Independent input" style="width: 240px" /><HuiButton
>Independent button</HuiButton
></HuiInputGroup
>
</HuiSpace>
</template>
Showing and Hiding Items
<script setup lang="ts">
import { ref } from 'vue'
import {
HuiInputGroup,
HuiInputGroupAddon,
HuiInput,
HuiButton,
HuiSwitch,
HuiSpace
} from '@nscode/handy-ui'
const prefix = ref(true)
const action = ref(true)
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiSpace
><span>Prefix</span><HuiSwitch v-model="prefix" /><span>Button</span
><HuiSwitch v-model="action"
/></HuiSpace>
<HuiInputGroup
><HuiInputGroupAddon v-if="prefix">Prefix</HuiInputGroupAddon
><HuiInput placeholder="Edges follow visible items" style="width: 240px" /><HuiButton
:style="{ display: action ? undefined : 'none' }"
>Action</HuiButton
></HuiInputGroup
>
</HuiSpace>
</template>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| size | ComponentSize | - | Shared size; explicit control size takes priority |
| disabled | boolean | false | Provide a disabled state to descendant controls |
| block | boolean | false | Fill the parent; input controls without inline widths share remaining space |
HuiInputGroupAddon has no custom props. Native attributes, class, style, and its default slot pass through to the addon element.
Events
No dedicated events. Bind values and interaction events to the individual controls.
Slots
| Component | Slot | Parameters | Description |
|---|---|---|---|
| HuiInputGroup | default | - | Controls that should join directly |
| HuiInputGroupAddon | default | - | Attached text or an icon |
Methods
No public methods. Use each control's own methods such as focus.
Types
import type { InputGroupProps, ComponentSize } from '@nscode/handy-ui'
interface InputGroupProps {
size?: ComponentSize
disabled?: boolean
block?: boolean
}