mango-ui-v3/components/Checkbox.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-09-24 05:24:17 -07:00
import React from 'react'
import { CheckIcon } from '@heroicons/react/solid'
const Checkbox = ({ checked, children, disabled = false, ...props }) => (
<label className="flex cursor-pointer items-center text-th-fgd-3">
<input
checked={checked}
{...props}
disabled={disabled}
type="checkbox"
style={{
border: '0',
clip: 'rect(0 0 0 0)',
clipPath: 'inset(50%)',
height: '1px',
margin: '-1px',
overflow: 'hidden',
padding: '0',
position: 'absolute',
whiteSpace: 'nowrap',
width: '1px',
}}
/>
2021-09-24 05:24:17 -07:00
<div
className={`${
checked && !disabled ? 'border-th-primary' : 'border-th-fgd-4'
} default-transition flex h-4 w-4 cursor-pointer items-center justify-center rounded border`}
2021-09-24 05:24:17 -07:00
>
<CheckIcon
className={`${checked ? 'block' : 'hidden'} h-4 w-4 ${
disabled ? 'text-th-fgd-4' : 'text-th-primary'
}`}
2021-09-24 05:24:17 -07:00
/>
</div>
2021-10-31 04:21:22 -07:00
<span className="ml-2 text-xs">{children}</span>
2021-09-26 06:20:51 -07:00
</label>
2021-09-24 05:24:17 -07:00
)
export default Checkbox