Skip to content

Commit acaedf2

Browse files
committed
refactor(styled textarea): improve handling of name/id props
1 parent b257895 commit acaedf2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/kit-styled/src/components/textarea/textarea.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ type TextareaProps = PropsOf<'textarea'> & {
55
error?: string;
66
};
77

8-
export const Textarea = component$<TextareaProps>(({ name, error, ...props }) => {
8+
export const Textarea = component$<TextareaProps>(({ id, name, error, ...props }) => {
9+
const textareaId = id || name;
910
return (
1011
<>
1112
<textarea
@@ -14,8 +15,9 @@ export const Textarea = component$<TextareaProps>(({ name, error, ...props }) =>
1415
'[&::-webkit-scrollbar-track]:bg-blue flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
1516
props.class,
1617
)}
18+
id={textareaId}
1719
/>
18-
{error && <div id={`${name}-error`}>{error}</div>}
20+
{error && <div id={`${textareaId}-error`}>{error}</div>}
1921
</>
2022
);
2123
});

0 commit comments

Comments
 (0)