diff --git a/packages/forms/src/index.ts b/packages/forms/src/index.ts index fa98ea5..5cea987 100644 --- a/packages/forms/src/index.ts +++ b/packages/forms/src/index.ts @@ -1,3 +1,4 @@ export * from './lib/checkbox'; export * from './lib/input'; export * from './lib/toggle'; +export * from './lib/textarea'; \ No newline at end of file diff --git a/packages/forms/src/lib/textarea/index.tsx b/packages/forms/src/lib/textarea/index.tsx new file mode 100644 index 0000000..7b5491d --- /dev/null +++ b/packages/forms/src/lib/textarea/index.tsx @@ -0,0 +1,93 @@ +import React, { ReactNode, useId } from 'react'; +import { cn } from "@bootwind/common" + +type TextareaVariant = "default" | "error" | "warning" | "success" +export interface TextareaProps extends React.TextareaHTMLAttributes { + id?: string + className?: string + name?: string + variant?: TextareaVariant + label?: string + placeholder?: string + filled?: boolean + disabled?: boolean + description?: string | ReactNode + leftSection?: string | ReactNode + rightSection?: string | ReactNode +} +export const Textarea: React.FC = ({ + id = useId(), + label, + className, + variant = "default", + description, + name, + placeholder, + disabled = false, + filled=true, + leftSection, + rightSection, + ...props +}) => { + const variantMap: Record = { + error: { + input: 'bg-red-50 focus:bg-white border-red-300 focus:border-red-500', + filled: 'bg-red-50', + description: 'text-red-500', + }, + default: { + input: 'border-gray-300 focus:bg-white hover:border-gray-900 focus:border-gray-500', + filled: 'bg-gray-100', + description: 'text-zinc-500', + }, + success: { + input: 'bg-green-50 focus:bg-white border-green-300 hover:border-green-900 focus:border-green-500', + filled: 'bg-green-50', + description: 'text-green-500', + }, + warning: { + input: 'bg-orange-50 focus:bg-white border-orange-300 hover:border-orange-900 focus:border-orange-500', + filled: 'bg-orange-50', + description: 'text-orange-500', + }, + } + const classes = variantMap[variant] + const inputClasses = `transition duration-200 placeholder:text-gray-400 + focus:ring-4 + text-gray-900 + py-2.5 px-3.5 + w-80 max-w-full + focus:ring-0 disabled:border-gray-200 + disabled:bg-transparent + disabled:cursor-not-allowed + ${classes.input} + ${leftSection ? 'pl-14' : ''} + ${rightSection ? 'pr-14' : ''} + ${filled ? 'border-0 border-b rounded-none' + classes.filled : 'border rounded-lg'} + ` + return ( +
+ { label && ( +
+ +
+ )} +
+ {leftSection && ( + + )} +