From 52a4b1d466d60d584c2abd106905977c082abadd Mon Sep 17 00:00:00 2001 From: shadcn Date: Mon, 19 Jan 2026 13:56:42 +0400 Subject: [PATCH] feat: add input-group --- .../docs/components/base/input-group.mdx | 154 +++++++++--------- .../docs/components/radix/input-group.mdx | 149 +++++++++-------- apps/v4/examples/__index__.tsx | 130 +++++++++++++++ .../examples/base/input-group-block-end.tsx | 49 ++++++ .../examples/base/input-group-block-start.tsx | 56 +++++++ apps/v4/examples/base/input-group-demo.tsx | 102 +----------- .../v4/examples/base/input-group-dropdown.tsx | 10 +- .../examples/base/input-group-inline-end.tsx | 26 +++ .../base/input-group-inline-start.tsx | 22 +++ apps/v4/examples/base/input-group-kbd.tsx | 21 +++ apps/v4/examples/base/input-group-spinner.tsx | 16 +- .../examples/base/input-group-with-addons.tsx | 2 + .../base/input-group-with-tooltip.tsx | 4 +- .../examples/radix/input-group-block-end.tsx | 49 ++++++ .../radix/input-group-block-start.tsx | 56 +++++++ apps/v4/examples/radix/input-group-demo.tsx | 100 +----------- .../examples/radix/input-group-inline-end.tsx | 26 +++ .../radix/input-group-inline-start.tsx | 22 +++ apps/v4/examples/radix/input-group-kbd.tsx | 21 +++ .../v4/examples/radix/input-group-spinner.tsx | 16 +- 20 files changed, 668 insertions(+), 363 deletions(-) create mode 100644 apps/v4/examples/base/input-group-block-end.tsx create mode 100644 apps/v4/examples/base/input-group-block-start.tsx create mode 100644 apps/v4/examples/base/input-group-inline-end.tsx create mode 100644 apps/v4/examples/base/input-group-inline-start.tsx create mode 100644 apps/v4/examples/base/input-group-kbd.tsx create mode 100644 apps/v4/examples/radix/input-group-block-end.tsx create mode 100644 apps/v4/examples/radix/input-group-block-start.tsx create mode 100644 apps/v4/examples/radix/input-group-inline-end.tsx create mode 100644 apps/v4/examples/radix/input-group-inline-start.tsx create mode 100644 apps/v4/examples/radix/input-group-kbd.tsx diff --git a/apps/v4/content/docs/components/base/input-group.mdx b/apps/v4/content/docs/components/base/input-group.mdx index 61fad7c6a8..3234106697 100644 --- a/apps/v4/content/docs/components/base/input-group.mdx +++ b/apps/v4/content/docs/components/base/input-group.mdx @@ -1,6 +1,6 @@ --- title: Input Group -description: Display additional information or actions to an input or textarea. +description: Add addons, buttons, and helper content to inputs. base: base component: true --- @@ -10,7 +10,7 @@ import { IconInfoCircle } from "@tabler/icons-react" ## Installation @@ -68,12 +68,59 @@ import { - - Search - ``` +## Align + +Use the `align` prop on `InputGroupAddon` to position the addon relative to the input. + + + For proper focus management, `InputGroupAddon` should always be placed after + `InputGroupInput` or `InputGroupTextarea` in the DOM. Use the `align` prop to + visually position the addon. + + +### inline-start + +Use `align="inline-start"` to position the addon at the start of the input. This is the default. + + + +### inline-end + +Use `align="inline-end"` to position the addon at the end of the input. + + + +### block-start + +Use `align="block-start"` to position the addon above the input. + + + +### block-end + +Use `align="block-end"` to position the addon below the input. + + + ## Examples ### Icon @@ -81,119 +128,69 @@ import { ### Text -Display additional text information alongside inputs. - ### Button -Add buttons to perform actions within the input group. - -### Tooltip - -Add tooltips to provide additional context or help. +### Kbd - -### Textarea - -Input groups also work with textarea components. Use `block-start` or `block-end` for alignment. - - - -### Spinner - -Show loading indicators while processing input. - - - -### Label - -Add labels within input groups to improve accessibility. - - ### Dropdown -Pair input groups with dropdown menus for complex interactions. - -### Button Group - -Wrap input groups with button groups to create prefixes and suffixes. +### Spinner + +### Textarea + + ### Custom Input -Add the `data-slot="input-group-control"` attribute to your custom input for automatic behavior and focus state handling. +Add the `data-slot="input-group-control"` attribute to your custom input for automatic focus state handling. -No style is applied to the custom input. Apply your own styles using the `className` prop. +Here's an example of a custom resizable textarea from a third-party library. -```tsx showLineNumbers -import { InputGroup, InputGroupAddon } from "@/component/ui/input-group" -import TextareaAutosize from "react-textarea-autosize" - -export function InputGroupCustom() { - return ( - - - how - - ) -} -``` - ## API Reference ### InputGroup @@ -297,8 +294,3 @@ All other props are passed through to the underlying `