123456789101112131415161718192021222324252627282930313233 |
- import { DetailedHTMLProps, InputHTMLAttributes } from 'react'
- type ICheckbox = {
- value?: boolean
- label?: string
- } & Omit<
- DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
- 'value'
- >
- const Checkbox = ({
- name,
- label,
- id,
- value = false,
- type,
- ...props
- }: ICheckbox) => {
- return (
- <>
- {label && <label htmlFor={id || name}>{label}</label>}
- <input
- id={id || label}
- name={name}
- checked={value}
- type='checkbox'
- {...props}
- />
- </>
- )
- }
- export default Checkbox
|