manifold/web/components/checkbox.tsx

34 lines
899 B
TypeScript
Raw Permalink Normal View History

2022-06-06 01:57:49 +00:00
import clsx from 'clsx'
export function Checkbox(props: {
label: string
checked: boolean
toggle: (checked: boolean) => void
className?: string
disabled?: boolean
2022-06-06 01:57:49 +00:00
}) {
const { label, checked, toggle, className, disabled } = props
2022-06-06 01:57:49 +00:00
return (
<div className={clsx(className, 'space-y-5')}>
<div className="relative flex items-center">
2022-06-06 01:57:49 +00:00
<div className="flex h-6 items-center">
<input
id={label}
type="checkbox"
className="h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
checked={checked}
onChange={(e) => toggle(!e.target.checked)}
disabled={disabled}
2022-06-06 01:57:49 +00:00
/>
</div>
<div className="ml-3">
<label htmlFor={label} className="font-medium text-gray-700">
{label}
</label>
</div>
</div>
</div>
)
}