tasko/components/form/form-submit.tsx
2024-02-15 20:49:19 -05:00

41 lines
724 B
TypeScript

'Use client';
import { useFormStatus } from 'react-dom';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
interface FormSubmitProps {
children: React.ReactNode;
disabled?: boolean;
className?: string;
variant?:
| 'default'
| 'destructive'
| 'outline'
| 'secondary'
| 'ghost'
| 'link'
| 'primary';
}
export const FormSubmit = ({
children,
disabled,
className,
variant = 'primary',
}: FormSubmitProps) => {
const { pending } = useFormStatus();
return (
<Button
disabled={pending || disabled}
type='submit'
variant={variant}
size='sm'
className={cn(className)}
>
{children}
</Button>
);
};