20 lines
962 B
TypeScript
20 lines
962 B
TypeScript
import { cn } from './utils';
|
|
import type { VariantProps } from 'class-variance-authority';
|
|
import { cva } from 'class-variance-authority';
|
|
import { forwardRef } from 'react';
|
|
|
|
const variants = cva(
|
|
'focus:ring-0 min-h-[36px] resize-y h-auto hover:border-primary-500 focus:border-primary-500 w-full rounded-sm border disabled:hover:border-gray-300 border-gray-300 p-2 px-3 text-sm text-gray-900 outline-none transition-colors ease-in-out disabled:cursor-not-allowed disabled:text-opacity-30'
|
|
);
|
|
|
|
export type TextAreaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement> &
|
|
VariantProps<typeof variants> & { readonly loading?: boolean };
|
|
|
|
export const Textarea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
({ className, loading, ...props }, ref) => {
|
|
if (loading) return <div className="h-[98px] w-full animate-pulse rounded bg-gray-100" />;
|
|
|
|
return <textarea rows={4} ref={ref} className={cn(variants({ className }))} {...props} />;
|
|
}
|
|
);
|