-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextArea.tsx
More file actions
60 lines (55 loc) · 1.36 KB
/
TextArea.tsx
File metadata and controls
60 lines (55 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { ComponentProps } from 'react';
import { cn } from '@/shared/lib/core';
import { Flex } from '../Flex';
import { Caption1 } from '../Typography';
type TextAreaProps = {
/**
* Current value of the textarea
*/
value: string;
/**
* Default height in number of rows
* @default 3
*/
rows?: number;
/**
* Whether to show character counter
* @default false
*/
showCounter?: boolean;
/**
* Custom class name for styling
*/
className?: string;
/**
* Custom class name for Wrapper styling
*/
wrapperClassName?: string;
} & Omit<ComponentProps<'textarea'>, 'rows'>;
export function TextArea({
value,
rows = 3,
showCounter = false,
className,
wrapperClassName,
...props
}: TextAreaProps) {
return (
<Flex dir="col" gap={2} className={wrapperClassName}>
<textarea
rows={rows}
className={cn(
'w-full resize-none rounded-xl border-none bg-white px-4 py-3.5 text-gray-900 outline-1 outline-gray-200 transition-colors placeholder:text-gray-400 focus:ring-4 focus:ring-blue-200 focus:outline-blue-500',
className
)}
value={value}
{...props}
/>
{showCounter && props.maxLength && (
<Caption1 weight="normal" className="text-right text-gray-500">
{value.length ?? 0}/{props.maxLength}
</Caption1>
)}
</Flex>
);
}