checkbox-with-label.tsx 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import cn from '@/utils/classnames'
  5. import Checkbox from '@/app/components/base/checkbox'
  6. import Tooltip from '@/app/components/base/tooltip'
  7. type Props = {
  8. className?: string
  9. isChecked: boolean
  10. onChange: (isChecked: boolean) => void
  11. label: string
  12. labelClassName?: string
  13. tooltip?: string
  14. }
  15. const CheckboxWithLabel: FC<Props> = ({
  16. className = '',
  17. isChecked,
  18. onChange,
  19. label,
  20. labelClassName,
  21. tooltip,
  22. }) => {
  23. return (
  24. <label className={cn(className, 'flex items-center h-7 space-x-2')}>
  25. <Checkbox checked={isChecked} onCheck={() => onChange(!isChecked)} />
  26. <div className={cn(labelClassName, 'text-sm font-normal text-gray-800')}>{label}</div>
  27. {tooltip && (
  28. <Tooltip
  29. popupContent={
  30. <div className='w-[200px]'>{tooltip}</div>
  31. }
  32. triggerClassName='ml-0.5 w-4 h-4'
  33. />
  34. )}
  35. </label>
  36. )
  37. }
  38. export default React.memo(CheckboxWithLabel)