checkbox-with-label.tsx 732 B

1234567891011121314151617181920212223242526272829
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import cn from 'classnames'
  5. import Checkbox from '@/app/components/base/checkbox'
  6. type Props = {
  7. className?: string
  8. isChecked: boolean
  9. onChange: (isChecked: boolean) => void
  10. label: string
  11. labelClassName?: string
  12. }
  13. const CheckboxWithLabel: FC<Props> = ({
  14. className = '',
  15. isChecked,
  16. onChange,
  17. label,
  18. labelClassName,
  19. }) => {
  20. return (
  21. <label className={cn(className, 'flex items-center h-7 space-x-2')}>
  22. <Checkbox checked={isChecked} onCheck={() => onChange(!isChecked)} />
  23. <div className={cn(labelClassName, 'text-sm font-normal text-gray-800')}>{label}</div>
  24. </label>
  25. )
  26. }
  27. export default React.memo(CheckboxWithLabel)