Skip to content

Commit f7967e7

Browse files
committed
fix: update InputGroup to match latest shadcn patterns
- Update InputGroupAddon align prop to use inline-start/inline-end (and block-start/block-end) - Add min-w-0 class to InputGroup component per shadcn changelog - Fix className prop conflict in TextField (only apply to FormItem, not InputGroupInput) - Update TextField to use correct align values
1 parent 3e185f0 commit f7967e7

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

packages/components/src/ui/input-group.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
1616
role="group"
1717
className={cn(
1818
// Simple wrapper with focus-within ring, matching original design
19-
'group flex w-full rounded-md transition-all duration-200',
19+
'group flex w-full min-w-0 rounded-md transition-all duration-200',
2020
'focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background',
2121
className,
2222
)}
@@ -27,22 +27,28 @@ function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
2727

2828
function InputGroupAddon({
2929
className,
30-
align = 'start',
30+
align = 'inline-start',
3131
...props
32-
}: React.ComponentProps<'div'> & { align?: 'start' | 'end' }) {
33-
const isPrefix = align === 'start';
34-
const isSuffix = align === 'end';
32+
}: React.ComponentProps<'div'> & { align?: 'inline-start' | 'inline-end' | 'block-start' | 'block-end' }) {
33+
const isInlineStart = align === 'inline-start';
34+
const isInlineEnd = align === 'inline-end';
35+
const isBlockStart = align === 'block-start';
36+
const isBlockEnd = align === 'block-end';
3537

3638
return (
3739
<div
3840
className={cn(
3941
// Base styling matching original FieldPrefix/FieldSuffix
4042
'flex h-10 items-center text-base text-gray-500 group-focus-within:text-gray-700 transition-colors duration-200',
4143
'border border-input bg-background',
42-
// Prefix styling (left side)
43-
isPrefix && 'pl-3 pr-0 rounded-l-md border-r-0',
44-
// Suffix styling (right side)
45-
isSuffix && 'pr-3 pl-0 rounded-r-md border-l-0',
44+
// Inline-start styling (left side)
45+
isInlineStart && 'pl-3 pr-0 rounded-l-md border-r-0',
46+
// Inline-end styling (right side)
47+
isInlineEnd && 'pr-3 pl-0 rounded-r-md border-l-0',
48+
// Block-start styling (above)
49+
isBlockStart && 'border-b-0 rounded-b-none',
50+
// Block-end styling (below)
51+
isBlockEnd && 'border-t-0 rounded-t-none',
4652
className,
4753
)}
4854
{...props}

packages/components/src/ui/text-field.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ export const TextField = function TextField({
5555
{label && <FormLabel Component={components?.FormLabel}>{label}</FormLabel>}
5656
{hasAddon ? (
5757
// New shadcn/ui InputGroup pattern
58+
// Note: Addons are placed after input in DOM for focus management, but align prop handles visual positioning
5859
<FormControl Component={components?.FormControl}>
5960
<InputGroup>
6061
{prefix && (
61-
<InputGroupAddon align="start">
62+
<InputGroupAddon align="inline-start">
6263
<InputGroupText>{prefix}</InputGroupText>
6364
</InputGroupAddon>
6465
)}
@@ -67,13 +68,13 @@ export const TextField = function TextField({
6768
{...props}
6869
ref={ref}
6970
aria-invalid={fieldState.error ? 'true' : 'false'}
70-
className={cn(className, {
71+
className={cn({
7172
'rounded-l-none border-l-0': prefix,
7273
'rounded-r-none border-r-0': suffix,
7374
})}
7475
/>
7576
{suffix && (
76-
<InputGroupAddon align="end">
77+
<InputGroupAddon align="inline-end">
7778
<InputGroupText>{suffix}</InputGroupText>
7879
</InputGroupAddon>
7980
)}
@@ -82,7 +83,7 @@ export const TextField = function TextField({
8283
) : (
8384
// Original pattern without addons
8485
<FormControl Component={components?.FormControl}>
85-
<InputComponent {...field} {...props} ref={ref} />
86+
<InputComponent {...field} {...props} ref={ref} className={className} />
8687
</FormControl>
8788
)}
8889
{description && <FormDescription Component={components?.FormDescription}>{description}</FormDescription>}

0 commit comments

Comments
 (0)