feat(components): Create UI components - Button, Input, Card, Checkbox
This commit is contained in:
48
frontend-next/components/Checkbox.tsx
Normal file
48
frontend-next/components/Checkbox.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* ✓ Checkbox Component
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
label?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
|
||||
({ label, error, id, className = '', ...props }, ref) => {
|
||||
const checkboxId = id || `checkbox-${Math.random()}`;
|
||||
|
||||
return (
|
||||
<div className="flex items-center">
|
||||
<input
|
||||
ref={ref}
|
||||
id={checkboxId}
|
||||
type="checkbox"
|
||||
className={`
|
||||
w-5
|
||||
h-5
|
||||
rounded
|
||||
border-gray-300
|
||||
text-blue-600
|
||||
focus:ring-blue-500
|
||||
cursor-pointer
|
||||
${error ? 'border-red-500' : 'border-gray-300'}
|
||||
${className}
|
||||
`}
|
||||
{...props}
|
||||
/>
|
||||
{label && (
|
||||
<label htmlFor={checkboxId} className="ml-2 text-gray-700 cursor-pointer">
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
{error && <p className="text-red-500 text-sm ml-2">{error}</p>}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Checkbox.displayName = 'Checkbox';
|
||||
|
||||
export default Checkbox;
|
||||
Reference in New Issue
Block a user