cal.pub0.org/apps/web/components/ui/form/CheckboxField.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

import React, { forwardRef, InputHTMLAttributes } from "react";
type Props = InputHTMLAttributes<HTMLInputElement> & {
label: React.ReactNode;
description: string;
};
const CheckboxField = forwardRef<HTMLInputElement, Props>(({ label, description, ...rest }, ref) => {
return (
<div className="block items-center sm:flex">
2022-02-09 22:32:31 +00:00
<div className="min-w-48 mb-4 sm:mb-0">
<label htmlFor={rest.id} className="flex text-sm font-medium text-neutral-700">
{label}
</label>
</div>
<div className="w-full">
<div className="relative flex items-start">
<div className="flex h-5 items-center">
<input
{...rest}
ref={ref}
type="checkbox"
2022-02-09 22:32:31 +00:00
className="text-primary-600 focus:ring-primary-500 h-4 w-4 rounded border-gray-300"
/>
</div>
<div className="text-sm ltr:ml-3 rtl:mr-3">
<p className="text-neutral-900">{description}</p>
</div>
</div>
</div>
</div>
);
});
CheckboxField.displayName = "CheckboxField";
export default CheckboxField;