Default
One hand-drawn box around an icon, the field and some text. Click anywhere on an addon and the field takes focus; the focus ring goes around the whole group.
One hand-drawn field around an icon, some text, a button and the control, so a search box or a URL field is a single box instead of three. The box takes the control's focus, invalid and disabled states, and grows with a textarea. The same parts as shadcn's Input Group.
npx shadcn@latest add @wobko/input-group第一次使用?先把 registry 加进 components.json。 如何安装
One hand-drawn box around an icon, the field and some text. Click anywhere on an addon and the field takes focus; the focus ring goes around the whole group.
Buttons go inside an addon (ghost, xs by default). The control's own state paints the group: aria-invalid draws the red box, disabled the dashed one, and `data-disabled` on the group disables it as a whole.
Block addons stack above or below a textarea inside the same drawn box: a header line on top, a counter and a send button underneath. The box grows with the text and is redrawn to fit.
A real-world use: a labeled group in a form. The label points at the control, the marker button is part of the same box, and a bad address turns the whole group red.
shadcn's `input-group-demo`: a search with a result count, a URL with a prefix and a tooltip button, a prompt box with a menu and a send button, and a field with a verified badge. The badge is a drawn `badge-check` where the original has a filled circle.
shadcn's `input-group-label`: a Label can be an addon, so the @ in front of a handle is a real label for the field, or a title above it (`block-start`) with a help button at the far end.
shadcn's `input-group-text`: `InputGroupText` sets plain words beside the field (a currency sign, a scheme, a domain) or under a textarea as a counter. The text is part of the box, not the value.
shadcn's `input-group-tooltip`: help buttons that explain themselves. Two sit at the end as ghost icon buttons; in the third the note opens to the left (`side="left"`), on the leading addon. The original makes the addon itself the trigger; here the button inside it is, so the tooltip is tied to the control that has focus.
shadcn's `input-group-button`: a copy button that turns into a tick, a popover from the button in the leading addon (the button is the trigger, so it is the thing that says it is expanded), a star that toggles, and a text button that ends the box. The original's `useCopyToClipboard` hook is a few lines of state here.
shadcn's `input-group-button-group`: an InputGroup as the middle of a ButtonGroup, with `https://` and `.com` as text cells on either side. The first cell is a Label (`asChild`), so it focuses the field.
shadcn's `input-group-dropdown`: a menu opened from a button inside the box, once as an ellipsis icon and once as a labeled `Search In...` with a chevron. The menu drops from the button; the box stays put.
shadcn's `input-group-spinner`: `data-disabled` on the group dims the whole box while something is working, with a Spinner or a spinning icon in either addon and a word or two of status.
shadcn's `input-group-textarea`: a code box with a file name and two icon buttons above (`block-start` plus `border-b`) and a cursor position and a Run button below. The corner-down-left glyph is not drawn yet, so Run wears a play icon.
shadcn's `input-group-icon`: icons as addons, at the start, at the end, or two together. They are drawn glyphs, not fonts, so each one is a slightly different line.
shadcn's `input-group-custom`: any control can be the group's field if it carries `data-slot="input-group-control"`. The original uses react-textarea-autosize; this one is a plain textarea with `field-sizing: content`, which grows with the text without a package.
The group: a `<div role="group">` that is the ink host. It draws the Input's pencil box once (rest), a red one (invalid) and a dashed one (disabled) as additive layers that follow the control in CSS. The control must be a direct child for the theme's own selectors; a deeper control works through `has-[...]` classes. `data-disabled` and `data-invalid` on the group work by hand.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| seed | string | number | - | Pins the hand: the same seed always draws the same box. Default: derived from useId(). |
Something beside or above/below the control. It is a role=group; clicking it focuses the control, except when the click lands on a button, link, select or another control inside it.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| align | "inline-start" | "inline-end" | "block-start" | "block-end" | "inline-start" | Where it sits. The block alignments stack it above or below the control and make the group grow taller. |
A Button for an addon: ghost by default. Put it inside an InputGroupAddon (a disabled button directly in the group would make the whole group look disabled).
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| size | "xs" | "sm" | "icon-xs" | "icon-sm" | "xs" | 24 px, 32 px, or the square versions. All Button variants work. |
CLI 会复制进你项目的文件。
正在加载源码