Skip to content

Commit 1d44933

Browse files
committed
feat: enhance TextField component with additional className props
- Updated TextInputProps interface to include groupClassName, prefixClassName, and suffixClassName for better customization. - Modified TextField component to utilize new className props for FieldPrefix and FieldSuffix, improving styling flexibility.
1 parent a581d43 commit 1d44933

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdacurry/forms",
3-
"version": "0.19.1",
3+
"version": "0.19.2",
44
"type": "module",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,17 @@ export const FieldSuffix = ({
5454
export interface TextInputProps extends Omit<InputProps, 'prefix' | 'suffix'> {
5555
control?: Control<FieldValues>;
5656
name: FieldPath<FieldValues>;
57-
label?: string | React.ReactNode;
57+
label?: string;
5858
description?: string;
5959
components?: Partial<FieldComponents> & {
6060
Input?: React.ComponentType<InputProps & React.RefAttributes<HTMLInputElement>>;
6161
};
6262
prefix?: React.ReactNode;
6363
suffix?: React.ReactNode;
6464
className?: string;
65+
groupClassName?: string;
66+
prefixClassName?: string;
67+
suffixClassName?: string;
6568
}
6669

6770
export const TextField = function TextField({
@@ -74,6 +77,9 @@ export const TextField = function TextField({
7477
prefix,
7578
suffix,
7679
ref,
80+
groupClassName,
81+
prefixClassName,
82+
suffixClassName,
7783
...props
7884
}: TextInputProps & { ref?: React.Ref<HTMLInputElement> }) {
7985
// Use the custom Input component if provided, otherwise use the default TextInput
@@ -91,10 +97,10 @@ export const TextField = function TextField({
9197
className={cn('flex group transition-all duration-200 rounded-md', {
9298
'field__input--with-prefix': prefix,
9399
'field__input--with-suffix': suffix,
94-
'focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background': true,
95-
})}
100+
'focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background': true
101+
}, groupClassName)}
96102
>
97-
{prefix && <FieldPrefix>{prefix}</FieldPrefix>}
103+
{prefix && <FieldPrefix className={prefixClassName}>{prefix}</FieldPrefix>}
98104
<FormControl Component={components?.FormControl}>
99105
<InputComponent
100106
{...field}
@@ -106,7 +112,7 @@ export const TextField = function TextField({
106112
})}
107113
/>
108114
</FormControl>
109-
{suffix && <FieldSuffix>{suffix}</FieldSuffix>}
115+
{suffix && <FieldSuffix className={suffixClassName}>{suffix}</FieldSuffix>}
110116
</div>
111117
{description && <FormDescription Component={components?.FormDescription}>{description}</FormDescription>}
112118
{fieldState.error && (

0 commit comments

Comments
 (0)